From eb529f90503199deb6cdcfdbf74383ee0e3dfaf2 Mon Sep 17 00:00:00 2001
From: Kima <kimavideos97@gmail.com>
Date: Sat, 27 May 2023 13:04:45 +0200
Subject: [PATCH] finally working account switcher

---
 .vscode/launch.json                                      | 2 +-
 .../lib/common/profile_image/profile_button.dart         | 9 +++++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/.vscode/launch.json b/.vscode/launch.json
index 8cc3a0f..70febd0 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -10,7 +10,7 @@
       "request": "launch",
       "type": "dart",
       "toolArgs": [
-        "--dart-define=APPVER=$(cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1)"
+        "--dart-define=APPVER=$(cat pubspec.yaml | grep version: | cut -d' ' -f2 | cut -d+ -f1) --release"
       ]
     }
   ]
diff --git a/filcnaplo_mobile_ui/lib/common/profile_image/profile_button.dart b/filcnaplo_mobile_ui/lib/common/profile_image/profile_button.dart
index b685862..59b59ae 100755
--- a/filcnaplo_mobile_ui/lib/common/profile_image/profile_button.dart
+++ b/filcnaplo_mobile_ui/lib/common/profile_image/profile_button.dart
@@ -43,7 +43,12 @@ class ProfileButton extends StatelessWidget {
 
     user = Provider.of<UserProvider>(context);
     try {
-      account = user.getUsers()[1];
+      user.getUsers().forEach((acc) {
+        if (user.name!.toLowerCase().replaceAll(' ', '') !=
+            acc.name.toLowerCase().replaceAll(' ', '')) {
+          account = acc;
+        }
+      });
     } catch (err) {
       account = null;
     }
@@ -83,7 +88,7 @@ class ProfileButton extends StatelessWidget {
       },
       onDoubleTap: () {
         if (account != null) {
-          user.setUser(account.id);
+          user.setUser(account!.id);
           restore().then((_) => user.setUser(account!.id));
         }
       },