From aa22579b8b15b6be1bba1281e92ad6c573485489 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:15:29 +0200 Subject: [PATCH 1/2] fix: Fix migration --- .../ViewAlarmScreen.dart | 1 + .../ViewAlarmSelectRadiusBasedScreen.dart | 1 + .../location_alarm_service/enums.dart | 2 ++ lib/services/task_service/task.dart | 5 ++-- lib/services/view_service/view.dart | 26 ++++++++++--------- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart b/lib/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart index b1411f4..9249fd3 100644 --- a/lib/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart +++ b/lib/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart @@ -313,6 +313,7 @@ class _ViewAlarmScreenState extends State { final child = (() { switch (alarm.IDENTIFIER) { case LocationAlarmType.geo: + case LocationAlarmType.radiusBasedRegion: return GeoLocationAlarmPreview( view: widget.view, alarm: alarm as GeoLocationAlarm, diff --git a/lib/screens/view_alarm_screen_widgets/ViewAlarmSelectRadiusBasedScreen.dart b/lib/screens/view_alarm_screen_widgets/ViewAlarmSelectRadiusBasedScreen.dart index 6e387cf..462cfa8 100644 --- a/lib/screens/view_alarm_screen_widgets/ViewAlarmSelectRadiusBasedScreen.dart +++ b/lib/screens/view_alarm_screen_widgets/ViewAlarmSelectRadiusBasedScreen.dart @@ -216,6 +216,7 @@ class _ViewAlarmSelectRadiusBasedScreenState switch (widget.type) { case LocationAlarmType.geo: + case LocationAlarmType.radiusBasedRegion: alarm = await showPlatformModalSheet( context: context, material: MaterialModalSheetData( diff --git a/lib/services/location_alarm_service/enums.dart b/lib/services/location_alarm_service/enums.dart index 27a3fe4..4ffb93d 100644 --- a/lib/services/location_alarm_service/enums.dart +++ b/lib/services/location_alarm_service/enums.dart @@ -7,6 +7,8 @@ enum LocationAlarmTriggerType { enum LocationAlarmType { geo, proximity, + // Required for migration, same as `geo` + radiusBasedRegion, } enum LocationRadiusBasedTriggerType { diff --git a/lib/services/task_service/task.dart b/lib/services/task_service/task.dart index 25874c3..5c99191 100644 --- a/lib/services/task_service/task.dart +++ b/lib/services/task_service/task.dart @@ -73,8 +73,9 @@ class Task extends ChangeNotifier with LocationBase { throw Exception("Unknown timer type"); } })), - outstandingLocations: Map.from(json["outstandingLocations"]) - .map( + outstandingLocations: + Map.from(json["outstandingLocations"] ?? {}) + .map( (rawLocationData, tries) => MapEntry( LocationPointService.fromJSON(jsonDecode(rawLocationData)), tries, diff --git a/lib/services/view_service/view.dart b/lib/services/view_service/view.dart index 34e12fe..ef41626 100644 --- a/lib/services/view_service/view.dart +++ b/lib/services/view_service/view.dart @@ -49,8 +49,7 @@ class TaskView extends ChangeNotifier with LocationBase { String? id, DateTime? lastAlarmCheck, List? alarms, - }) - : _encryptionPassword = encryptionPassword, + }) : _encryptionPassword = encryptionPassword, alarms = alarms ?? [], lastAlarmCheck = lastAlarmCheck ?? DateTime.now(), id = id ?? const Uuid().v4(); @@ -62,7 +61,7 @@ class TaskView extends ChangeNotifier with LocationBase { final fragment = uri.fragment; final rawParameters = - const Utf8Decoder().convert(base64Url.decode(fragment)); + const Utf8Decoder().convert(base64Url.decode(fragment)); final parameters = jsonDecode(rawParameters); return ViewServiceLinkParameters( @@ -76,10 +75,9 @@ class TaskView extends ChangeNotifier with LocationBase { ); } - factory TaskView.fromJSON(final Map json) => - TaskView( + factory TaskView.fromJSON(final Map json) => TaskView( encryptionPassword: - SecretKey(List.from(json["encryptionPassword"])), + SecretKey(List.from(json["encryptionPassword"])), nostrPublicKey: json["nostrPublicKey"], relays: List.from(json["relays"]), name: json["name"] ?? "Unnamed Task", @@ -92,6 +90,7 @@ class TaskView extends ChangeNotifier with LocationBase { switch (identifier) { case LocationAlarmType.geo: + case LocationAlarmType.radiusBasedRegion: return GeoLocationAlarm.fromJSON(alarm); case LocationAlarmType.proximity: return ProximityLocationAlarm.fromJSON(alarm); @@ -109,8 +108,10 @@ class TaskView extends ChangeNotifier with LocationBase { : Colors.primaries[Random().nextInt(Colors.primaries.length)], ); - static Future fetchFromNostr(final AppLocalizations l10n, - final ViewServiceLinkParameters parameters,) async { + static Future fetchFromNostr( + final AppLocalizations l10n, + final ViewServiceLinkParameters parameters, + ) async { final completer = Completer(); final request = Request(generate64RandomHexChars(), [ @@ -152,7 +153,7 @@ class TaskView extends ChangeNotifier with LocationBase { relays: List.from(data['relays']), name: l10n.longFormattedDate(DateTime.now()), color: - Colors.primaries[Random().nextInt(Colors.primaries.length)], + Colors.primaries[Random().nextInt(Colors.primaries.length)], ), ); } catch (error) { @@ -199,7 +200,8 @@ class TaskView extends ChangeNotifier with LocationBase { }; } - Future validate(final AppLocalizations l10n, { + Future validate( + final AppLocalizations l10n, { required final TaskService taskService, required final ViewService viewService, }) async { @@ -208,14 +210,14 @@ class TaskView extends ChangeNotifier with LocationBase { } final sameTask = taskService.tasks.firstWhereOrNull( - (element) => element.nostrPublicKey == nostrPublicKey); + (element) => element.nostrPublicKey == nostrPublicKey); if (sameTask != null) { return l10n.taskImport_error_sameTask(sameTask.name); } final sameView = viewService.views.firstWhereOrNull( - (element) => element.nostrPublicKey == nostrPublicKey); + (element) => element.nostrPublicKey == nostrPublicKey); if (sameView != null) { return l10n.taskImport_error_sameView(sameView.name); From 2c99789f2ce772174938f2b35ab1f68d9ed74d9f Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Tue, 3 Oct 2023 22:20:25 +0200 Subject: [PATCH 2/2] chore: Update version --- lib/constants/values.dart | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/constants/values.dart b/lib/constants/values.dart index 8d9f838..bde1205 100644 --- a/lib/constants/values.dart +++ b/lib/constants/values.dart @@ -13,7 +13,7 @@ const LOCATION_INTERVAL = Duration(minutes: 1); const TRANSFER_DATA_USERNAME = "locus_transfer"; final TRANSFER_SUCCESS_MESSAGE = Uint8List.fromList([1, 2, 3, 4]); -const CURRENT_APP_VERSION = "0.15.0"; +const CURRENT_APP_VERSION = "0.15.1"; const LOG_TAG = "LocusLog"; diff --git a/pubspec.yaml b/pubspec.yaml index 4a8b576..af7f3a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.15.0+36 +version: 0.15.1+37 environment: sdk: '>=3.0.0'