loadFromOfflineCache method
Future<void>
loadFromOfflineCache(
)
Implementation
Future<void> loadFromOfflineCache() async {
try {
await ensureInitialized();
for (final tableName in _cache.registeredTableNames) {
if (_cache.isEventTable(tableName)) continue;
final rows = await _storage.loadTableSnapshot(tableName);
if (rows != null && rows.isNotEmpty) {
final table = _cache.getTableByName(tableName);
if (table != null && table.decoder.supportsJsonSerialization) {
table.loadFromSerializable(rows);
SdkLogger.d(
'Loaded ${rows.length} rows from offline cache for "$tableName"',
);
}
}
}
final pending = await _storage.getPendingMutations();
for (final mutation in pending) {
_optimisticState.applyOptimisticChanges(
mutation.requestId,
mutation.optimisticChanges,
);
}
await updatePendingCount();
} catch (e) {
SdkLogger.e('Error loading from offline cache: $e');
}
}