diff --git a/lib/app/data/providers/isar_provider.dart b/lib/app/data/providers/isar_provider.dart index 249dbf06..ef7ecd7f 100644 --- a/lib/app/data/providers/isar_provider.dart +++ b/lib/app/data/providers/isar_provider.dart @@ -378,21 +378,28 @@ class IsarDb { return profileSet; } + // Do some changes in the updateAlarmProfiles function to update the profile name in the alarms table static Future updateAlarmProfiles(String newName) async { final isarProvider = IsarDb(); final db = await isarProvider.db; final currentProfileName = await storage.readProfile(); + final currentProfile = await IsarDb.getProfile(currentProfileName); + if (currentProfile == null) { + + print("Got Error: Current profile '$currentProfileName' not found."); + return; + } List alarmsModels = await db.alarmModels .where() .filter() - .profileEqualTo(currentProfileName) + .profileEqualTo(currentProfileName) .findAll(); for (final item in alarmsModels) { item.profile = newName; - updateAlarm(item); + await updateAlarm(item); } - } +} static Future deleteAlarm(int id) async { final isarProvider = IsarDb();