Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit fb2500b

Browse files
authored
Merge pull request #128 from Myzel394/fix-migration
Fix migration
2 parents 92d19f9 + 2c99789 commit fb2500b

File tree

7 files changed

+23
-16
lines changed

7 files changed

+23
-16
lines changed

lib/constants/values.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const LOCATION_INTERVAL = Duration(minutes: 1);
1313
const TRANSFER_DATA_USERNAME = "locus_transfer";
1414
final TRANSFER_SUCCESS_MESSAGE = Uint8List.fromList([1, 2, 3, 4]);
1515

16-
const CURRENT_APP_VERSION = "0.15.0";
16+
const CURRENT_APP_VERSION = "0.15.1";
1717

1818
const LOG_TAG = "LocusLog";
1919

lib/screens/view_alarm_screen_widgets/ViewAlarmScreen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ class _ViewAlarmScreenState extends State<ViewAlarmScreen> {
313313
final child = (() {
314314
switch (alarm.IDENTIFIER) {
315315
case LocationAlarmType.geo:
316+
case LocationAlarmType.radiusBasedRegion:
316317
return GeoLocationAlarmPreview(
317318
view: widget.view,
318319
alarm: alarm as GeoLocationAlarm,

lib/screens/view_alarm_screen_widgets/ViewAlarmSelectRadiusBasedScreen.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ class _ViewAlarmSelectRadiusBasedScreenState
216216

217217
switch (widget.type) {
218218
case LocationAlarmType.geo:
219+
case LocationAlarmType.radiusBasedRegion:
219220
alarm = await showPlatformModalSheet(
220221
context: context,
221222
material: MaterialModalSheetData(

lib/services/location_alarm_service/enums.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ enum LocationAlarmTriggerType {
77
enum LocationAlarmType {
88
geo,
99
proximity,
10+
// Required for migration, same as `geo`
11+
radiusBasedRegion,
1012
}
1113

1214
enum LocationRadiusBasedTriggerType {

lib/services/task_service/task.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ class Task extends ChangeNotifier with LocationBase {
7373
throw Exception("Unknown timer type");
7474
}
7575
})),
76-
outstandingLocations: Map<String, int>.from(json["outstandingLocations"])
77-
.map<LocationPointService, int>(
76+
outstandingLocations:
77+
Map<String, int>.from(json["outstandingLocations"] ?? {})
78+
.map<LocationPointService, int>(
7879
(rawLocationData, tries) => MapEntry(
7980
LocationPointService.fromJSON(jsonDecode(rawLocationData)),
8081
tries,

lib/services/view_service/view.dart

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ class TaskView extends ChangeNotifier with LocationBase {
4949
String? id,
5050
DateTime? lastAlarmCheck,
5151
List<LocationAlarmServiceBase>? alarms,
52-
})
53-
: _encryptionPassword = encryptionPassword,
52+
}) : _encryptionPassword = encryptionPassword,
5453
alarms = alarms ?? [],
5554
lastAlarmCheck = lastAlarmCheck ?? DateTime.now(),
5655
id = id ?? const Uuid().v4();
@@ -62,7 +61,7 @@ class TaskView extends ChangeNotifier with LocationBase {
6261
final fragment = uri.fragment;
6362

6463
final rawParameters =
65-
const Utf8Decoder().convert(base64Url.decode(fragment));
64+
const Utf8Decoder().convert(base64Url.decode(fragment));
6665
final parameters = jsonDecode(rawParameters);
6766

6867
return ViewServiceLinkParameters(
@@ -76,10 +75,9 @@ class TaskView extends ChangeNotifier with LocationBase {
7675
);
7776
}
7877

79-
factory TaskView.fromJSON(final Map<String, dynamic> json) =>
80-
TaskView(
78+
factory TaskView.fromJSON(final Map<String, dynamic> json) => TaskView(
8179
encryptionPassword:
82-
SecretKey(List<int>.from(json["encryptionPassword"])),
80+
SecretKey(List<int>.from(json["encryptionPassword"])),
8381
nostrPublicKey: json["nostrPublicKey"],
8482
relays: List<String>.from(json["relays"]),
8583
name: json["name"] ?? "Unnamed Task",
@@ -92,6 +90,7 @@ class TaskView extends ChangeNotifier with LocationBase {
9290

9391
switch (identifier) {
9492
case LocationAlarmType.geo:
93+
case LocationAlarmType.radiusBasedRegion:
9594
return GeoLocationAlarm.fromJSON(alarm);
9695
case LocationAlarmType.proximity:
9796
return ProximityLocationAlarm.fromJSON(alarm);
@@ -109,8 +108,10 @@ class TaskView extends ChangeNotifier with LocationBase {
109108
: Colors.primaries[Random().nextInt(Colors.primaries.length)],
110109
);
111110

112-
static Future<TaskView> fetchFromNostr(final AppLocalizations l10n,
113-
final ViewServiceLinkParameters parameters,) async {
111+
static Future<TaskView> fetchFromNostr(
112+
final AppLocalizations l10n,
113+
final ViewServiceLinkParameters parameters,
114+
) async {
114115
final completer = Completer<TaskView>();
115116

116117
final request = Request(generate64RandomHexChars(), [
@@ -152,7 +153,7 @@ class TaskView extends ChangeNotifier with LocationBase {
152153
relays: List<String>.from(data['relays']),
153154
name: l10n.longFormattedDate(DateTime.now()),
154155
color:
155-
Colors.primaries[Random().nextInt(Colors.primaries.length)],
156+
Colors.primaries[Random().nextInt(Colors.primaries.length)],
156157
),
157158
);
158159
} catch (error) {
@@ -199,7 +200,8 @@ class TaskView extends ChangeNotifier with LocationBase {
199200
};
200201
}
201202

202-
Future<String?> validate(final AppLocalizations l10n, {
203+
Future<String?> validate(
204+
final AppLocalizations l10n, {
203205
required final TaskService taskService,
204206
required final ViewService viewService,
205207
}) async {
@@ -208,14 +210,14 @@ class TaskView extends ChangeNotifier with LocationBase {
208210
}
209211

210212
final sameTask = taskService.tasks.firstWhereOrNull(
211-
(element) => element.nostrPublicKey == nostrPublicKey);
213+
(element) => element.nostrPublicKey == nostrPublicKey);
212214

213215
if (sameTask != null) {
214216
return l10n.taskImport_error_sameTask(sameTask.name);
215217
}
216218

217219
final sameView = viewService.views.firstWhereOrNull(
218-
(element) => element.nostrPublicKey == nostrPublicKey);
220+
(element) => element.nostrPublicKey == nostrPublicKey);
219221

220222
if (sameView != null) {
221223
return l10n.taskImport_error_sameView(sameView.name);

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
1818
# In Windows, build-name is used as the major, minor, and patch parts
1919
# of the product and file versions while build-number is used as the build suffix.
20-
version: 0.15.0+36
20+
version: 0.15.1+37
2121

2222
environment:
2323
sdk: '>=3.0.0'

0 commit comments

Comments
 (0)