From 54c75ecbe53bec211380b418bec15fc5b61d5490 Mon Sep 17 00:00:00 2001 From: lollipopkit Date: Tue, 12 Dec 2023 16:16:15 +0800 Subject: [PATCH] fix: restore loop & opt. --- lib/app.dart | 11 +---------- lib/core/persistant_store.dart | 33 ++++----------------------------- lib/data/model/app/backup.dart | 3 +++ 3 files changed, 8 insertions(+), 39 deletions(-) diff --git a/lib/app.dart b/lib/app.dart index 85565a71b..98e93820d 100644 --- a/lib/app.dart +++ b/lib/app.dart @@ -13,14 +13,6 @@ import 'data/res/color.dart'; import 'view/page/full_screen.dart'; import 'view/page/home.dart'; -/// After upgrading to flutter 3.13, -/// the shadow color of the drawer is white (maybe a bug). -/// Only on [iOS]. -/// TODO: remember to remove it after the bug is fixed. -const _drawerTheme = DrawerThemeData( - shadowColor: Colors.black12, -); - class MyApp extends StatelessWidget { const MyApp({super.key}); @@ -54,7 +46,6 @@ class MyApp extends StatelessWidget { useMaterial3: true, brightness: Brightness.dark, colorSchemeSeed: primaryColor, - drawerTheme: _drawerTheme, ); return MaterialApp( @@ -92,7 +83,7 @@ class MyApp extends StatelessWidget { ThemeData _getAmoledTheme(ThemeData darkTheme) => darkTheme.copyWith( scaffoldBackgroundColor: Colors.black, dialogBackgroundColor: Colors.black, - drawerTheme: _drawerTheme.copyWith(backgroundColor: Colors.black), + drawerTheme: const DrawerThemeData(backgroundColor: Colors.black), appBarTheme: const AppBarTheme(backgroundColor: Colors.black), dialogTheme: const DialogTheme(backgroundColor: Colors.black), bottomSheetTheme: diff --git a/lib/core/persistant_store.dart b/lib/core/persistant_store.dart index d9bda710a..c632c8927 100644 --- a/lib/core/persistant_store.dart +++ b/lib/core/persistant_store.dart @@ -1,10 +1,8 @@ import 'dart:async'; -import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:toolbox/core/utils/misc.dart'; -import 'package:toolbox/data/res/path.dart'; // abstract final class SecureStore { // static const _secureStorage = FlutterSecureStorage(); @@ -42,32 +40,6 @@ class PersistentStore { boxName, //encryptionCipher: SecureStore._cipher, ); - - /// Get all db filenames. - /// - /// - [suffixs] defaults to ['.hive'] - /// - /// - If [hideSetting] is true, hide 'setting.hive' - static Future> getFileNames({ - bool hideSetting = false, - List? suffixs, - }) async { - final docPath = await Paths.doc; - final dir = Directory(docPath); - final files = await dir.list().toList(); - if (suffixs != null) { - files.removeWhere((e) => !suffixs.contains(e.path.split('.').last)); - } else { - // filter out non-hive(db) files - files.removeWhere((e) => !e.path.endsWith('.hive')); - } - if (hideSetting) { - files.removeWhere((e) => e.path.endsWith('setting.hive')); - } - final paths = - files.map((e) => e.path.replaceFirst('$docPath/', '')).toList(); - return paths; - } } extension BoxX on Box { @@ -85,7 +57,10 @@ extension BoxX on Box { return val; } - Future updateLastModified() => put(lastModifiedKey, timeStamp); + Future updateLastModified([int? time]) => put( + lastModifiedKey, + time ?? timeStamp, + ); /// Convert db to json Map toJson({bool includeInternal = true}) { diff --git a/lib/data/model/app/backup.dart b/lib/data/model/app/backup.dart index 2b610fa5f..ffc49f628 100644 --- a/lib/data/model/app/backup.dart +++ b/lib/data/model/app/backup.dart @@ -117,6 +117,9 @@ class Backup { } } + // update last modified time, avoid restore again + Stores.setting.box.updateLastModified(lastModTime); + Pros.reload(); RebuildNodes.app.rebuild();