some issues fixed
This commit is contained in:
@@ -25,20 +25,6 @@ List<BankTransaction> mergeBankTransactionLists(
|
||||
return mergeTransactions(local, remote);
|
||||
}
|
||||
|
||||
/// Union Overview favourites by client id (local wins on conflict).
|
||||
List<OverviewFavourite> mergeOverviewFavourites(
|
||||
List<OverviewFavourite> local,
|
||||
List<OverviewFavourite> remote,
|
||||
) {
|
||||
final byId = <String, OverviewFavourite>{
|
||||
for (final fav in remote) fav.id: fav,
|
||||
};
|
||||
for (final fav in local) {
|
||||
byId[fav.id] = fav;
|
||||
}
|
||||
return byId.values.toList(growable: false);
|
||||
}
|
||||
|
||||
/// Union-merge so neither device loses annotations on first sync.
|
||||
TxMetaStoreData mergeTxMetaStores(TxMetaStoreData a, TxMetaStoreData b) {
|
||||
final byId = <String, TxMeta>{...a.byId};
|
||||
@@ -485,6 +471,8 @@ class PbSyncService {
|
||||
),
|
||||
invertExpensePerspective:
|
||||
r.getBoolValue('invert_expense_perspective'),
|
||||
updatedAt: _recordUpdatedAtMs(r),
|
||||
deleted: r.getBoolValue('deleted'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -544,6 +532,8 @@ class PbSyncService {
|
||||
'showAmountIn': r.getBoolValue('show_amount_in', true),
|
||||
'showAmountOut': r.getBoolValue('show_amount_out', true),
|
||||
'showCount': r.getBoolValue('show_count', true),
|
||||
'updatedAt': _recordUpdatedAtMs(r),
|
||||
'deleted': r.getBoolValue('deleted'),
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -1364,6 +1354,8 @@ class PbSyncService {
|
||||
'flow': fav.flow.name,
|
||||
'bar_style': fav.barStyle.name,
|
||||
'invert_expense_perspective': fav.invertExpensePerspective,
|
||||
'updated_at': fav.updatedAt,
|
||||
'deleted': fav.deleted,
|
||||
};
|
||||
final remote = existing[clientId];
|
||||
if (remote == null) {
|
||||
@@ -1428,6 +1420,8 @@ class PbSyncService {
|
||||
'show_amount_in': w.showAmountIn,
|
||||
'show_amount_out': w.showAmountOut,
|
||||
'show_count': w.showCount,
|
||||
'updated_at': w.updatedAt,
|
||||
'deleted': w.deleted,
|
||||
};
|
||||
final remote = existing[clientId];
|
||||
if (remote == null) {
|
||||
@@ -1533,7 +1527,9 @@ class PbSyncService {
|
||||
remote.getStringValue('flow') == fav.flow.name &&
|
||||
remote.getStringValue('bar_style') == fav.barStyle.name &&
|
||||
remote.getBoolValue('invert_expense_perspective') ==
|
||||
fav.invertExpensePerspective;
|
||||
fav.invertExpensePerspective &&
|
||||
remote.getBoolValue('deleted') == fav.deleted &&
|
||||
_recordUpdatedAtMs(remote) == fav.updatedAt;
|
||||
}
|
||||
|
||||
bool _homeFilterWidgetUnchanged(RecordModel remote, HomeFilterWidget w) {
|
||||
@@ -1572,7 +1568,9 @@ class PbSyncService {
|
||||
remote.getBoolValue('month_only') == w.monthOnly &&
|
||||
remote.getBoolValue('show_amount_in', true) == w.showAmountIn &&
|
||||
remote.getBoolValue('show_amount_out', true) == w.showAmountOut &&
|
||||
remote.getBoolValue('show_count', true) == w.showCount;
|
||||
remote.getBoolValue('show_count', true) == w.showCount &&
|
||||
remote.getBoolValue('deleted') == w.deleted &&
|
||||
_recordUpdatedAtMs(remote) == w.updatedAt;
|
||||
}
|
||||
|
||||
bool _appPrefsUnchanged(RecordModel remote, AppCloudPrefs prefs) {
|
||||
@@ -1585,6 +1583,20 @@ class PbSyncService {
|
||||
remote.getIntValue('look_ahead_max_years', 5) ==
|
||||
prefs.lookAheadMaxYears.clamp(1, 30);
|
||||
}
|
||||
|
||||
/// Prefer custom `updated_at`, else PocketBase system `updated`.
|
||||
int _recordUpdatedAtMs(RecordModel r) {
|
||||
final raw = r.get<dynamic>('updated_at');
|
||||
final custom = switch (raw) {
|
||||
int n => n,
|
||||
num n => n.round(),
|
||||
String s => int.tryParse(s) ?? 0,
|
||||
_ => 0,
|
||||
};
|
||||
if (custom > 0) return custom;
|
||||
final system = DateTime.tryParse(r.getStringValue('updated'));
|
||||
return system?.millisecondsSinceEpoch ?? 0;
|
||||
}
|
||||
}
|
||||
|
||||
RecurringTemplateSource _parseTemplateSource(String raw) {
|
||||
|
||||
Reference in New Issue
Block a user