mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-19 00:04:22 +01:00
opt.: sync immediately after changes (#577)
This commit is contained in:
@@ -1,35 +1,38 @@
|
||||
import 'package:fl_lib/fl_lib.dart';
|
||||
import 'package:server_box/data/store/container.dart';
|
||||
import 'package:server_box/data/store/history.dart';
|
||||
import 'package:server_box/data/store/no_backup.dart';
|
||||
import 'package:server_box/data/store/private_key.dart';
|
||||
import 'package:server_box/data/store/server.dart';
|
||||
import 'package:server_box/data/store/setting.dart';
|
||||
import 'package:server_box/data/store/snippet.dart';
|
||||
|
||||
abstract final class Stores {
|
||||
static final setting = SettingStore();
|
||||
static final server = ServerStore();
|
||||
static final container = ContainerStore();
|
||||
static final history = HistoryStore();
|
||||
static final key = PrivateKeyStore();
|
||||
static final snippet = SnippetStore();
|
||||
static final setting = SettingStore.instance;
|
||||
static final server = ServerStore.instance;
|
||||
static final container = ContainerStore.instance;
|
||||
static final key = PrivateKeyStore.instance;
|
||||
static final snippet = SnippetStore.instance;
|
||||
static final history = HistoryStore.instance;
|
||||
|
||||
static final List<PersistentStore> all = [
|
||||
setting,
|
||||
server,
|
||||
container,
|
||||
history,
|
||||
key,
|
||||
snippet,
|
||||
/// All stores that need backup
|
||||
static final List<PersistentStore> _allBackup = [
|
||||
SettingStore.instance,
|
||||
ServerStore.instance,
|
||||
ContainerStore.instance,
|
||||
PrivateKeyStore.instance,
|
||||
SnippetStore.instance,
|
||||
HistoryStore.instance,
|
||||
];
|
||||
|
||||
static Future<void> init() async {
|
||||
await Future.wait(all.map((store) => store.init()));
|
||||
await Future.wait(_allBackup.map((store) => store.init()));
|
||||
await NoBackupStore.instance.init();
|
||||
}
|
||||
|
||||
static int? get lastModTime {
|
||||
int? lastModTime = 0;
|
||||
for (final store in all) {
|
||||
for (final store in _allBackup) {
|
||||
final last = store.box.lastModified ?? 0;
|
||||
if (last > (lastModTime ?? 0)) {
|
||||
lastModTime = last;
|
||||
|
||||
Reference in New Issue
Block a user