getRemoteTimestamps method
Get the last-modified timestamp for each synced table from the remote.
Used for the "smart sync gate" — compare remote timestamps against local timestamps to skip unchanged tables entirely.
Return a map of { tableName: lastModified }.
Tables not present in the map will be pulled unconditionally.
Implementation
@override
Future<Map<String, DateTime>> getRemoteTimestamps() async {
if (tableTimestampKeys.isEmpty) return {};
try {
final rows =
await client.from(syncStatusTable).select().eq('user_id', userId());
if (rows.isEmpty) return {};
final row = rows.first;
final result = <String, DateTime>{};
for (final entry in tableTimestampKeys.entries) {
final value = row[entry.value];
if (value != null) {
result[entry.key] = DateTime.parse(value.toString()).toUtc();
}
}
return result;
} on AuthException catch (e) {
throw AuthExpiredException(e);
} catch (e) {
if (_isAuthError(e)) throw AuthExpiredException(e);
// Rethrow so SyncEngine can catch and route to onError,
// avoiding a silent fallback to expensive full-syncs.
rethrow;
}
}