From 75e0a69eab6d8bbdb9b9195f9879d090452b877e Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 25 Jul 2022 14:26:26 +1000 Subject: [PATCH] Automatically add a demo server profile (#189) --- lib/user_profile.dart | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/user_profile.dart b/lib/user_profile.dart index 7f6cafd6..bee9a93a 100644 --- a/lib/user_profile.dart +++ b/lib/user_profile.dart @@ -190,6 +190,28 @@ class UserProfileDBManager { } } + // If there are no available profiles, create a demo profile + if (profileList.isEmpty) { + bool added = await InvenTreeSettingsManager().getBool("demo_profile_added", false); + + // Don't add a new profile if we have added it previously + if (!added) { + + await InvenTreeSettingsManager().setValue("demo_profile_added", true); + + UserProfile demoProfile = UserProfile( + name: "InvenTree Demo", + server: "https://demo.inventree.org", + username: "allaccess", + password: "nolimits", + ); + + await addProfile(demoProfile); + + profileList.add(demoProfile); + } + } + return profileList; }