Offline Support

This commit is contained in:
2026-04-27 06:20:39 +08:00
parent 7d8851a94a
commit 48cd3bcd60
121 changed files with 14798 additions and 2214 deletions
+8
View File
@@ -1,5 +1,6 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../brick/cache_helpers.dart';
import '../models/service.dart';
import 'supabase_provider.dart';
import 'stream_recovery.dart';
@@ -17,6 +18,13 @@ final servicesProvider = StreamProvider<List<Service>>((ref) {
fromMap: Service.fromMap,
channelName: 'services',
onStatusChanged: ref.read(realtimeControllerProvider).handleChannelStatus,
onOfflineData: () async {
final all = await cachedListFromBrick<Service>();
all.sort((a, b) => a.name.toLowerCase().compareTo(b.name.toLowerCase()));
return all;
},
onCacheMirror: (rows) =>
mirrorBatchToBrick<Service>(rows, tag: 'services'),
);
ref.onDispose(wrapper.dispose);