fix: auto reload after restoring
This commit is contained in:
@@ -6,7 +6,7 @@ class PrivateKeyProvider extends ChangeNotifier {
|
||||
List<PrivateKeyInfo> get pkis => _pkis;
|
||||
late List<PrivateKeyInfo> _pkis;
|
||||
|
||||
void loadData() {
|
||||
void load() {
|
||||
_pkis = Stores.key.fetch();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class ServerProvider extends ChangeNotifier {
|
||||
|
||||
Timer? _timer;
|
||||
|
||||
Future<void> loadLocalData() async {
|
||||
Future<void> load() async {
|
||||
// Issue #147
|
||||
// Clear all servers because of restarting app will cause duplicate servers
|
||||
_servers.clear();
|
||||
|
||||
@@ -13,7 +13,7 @@ class SnippetProvider extends ChangeNotifier {
|
||||
final _tags = <String>[];
|
||||
List<String> get tags => _tags;
|
||||
|
||||
void loadData() {
|
||||
void load() {
|
||||
_snippets = Stores.snippet.fetch();
|
||||
final order = Stores.setting.snippetOrder.fetch();
|
||||
if (order.isNotEmpty) {
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 572;
|
||||
static const int build = 574;
|
||||
static const String engine = "3.13.5";
|
||||
static const String buildAt = "2023-09-23 11:12:55";
|
||||
static const int modifications = 2;
|
||||
static const String buildAt = "2023-09-24 15:49:22";
|
||||
static const int modifications = 12;
|
||||
static const int script = 18;
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ class Providers {
|
||||
static final server = locator<ServerProvider>();
|
||||
static final sftp = locator<SftpProvider>();
|
||||
static final snippet = locator<SnippetProvider>();
|
||||
|
||||
static void reload() {
|
||||
key.load();
|
||||
server.load();
|
||||
snippet.load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,8 +92,8 @@ Future<void> initApp() async {
|
||||
}
|
||||
|
||||
void _setupProviders() {
|
||||
Providers.snippet.loadData();
|
||||
Providers.key.loadData();
|
||||
Providers.snippet.load();
|
||||
Providers.key.load();
|
||||
}
|
||||
|
||||
Future<void> _initHive() async {
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:toolbox/core/utils/rebuild.dart';
|
||||
import 'package:toolbox/data/model/app/backup.dart';
|
||||
import 'package:toolbox/data/res/logger.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
import 'package:toolbox/data/res/provider.dart';
|
||||
import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:toolbox/view/widget/round_rect_card.dart';
|
||||
|
||||
@@ -157,6 +158,7 @@ class BackupPage extends StatelessWidget {
|
||||
backup.restore();
|
||||
context.pop();
|
||||
RebuildNodes.app.rebuild();
|
||||
Providers.reload();
|
||||
},
|
||||
child: Text(l10n.ok),
|
||||
),
|
||||
|
||||
@@ -368,7 +368,7 @@ class _FullScreenPageState extends State<FullScreenPage> with AfterLayoutMixin {
|
||||
doUpdate(context);
|
||||
}
|
||||
await GetIt.I.allReady();
|
||||
await Providers.server.loadLocalData();
|
||||
await Providers.server.load();
|
||||
await Providers.server.refreshData();
|
||||
if (!Analysis.enabled) {
|
||||
await Analysis.init();
|
||||
|
||||
@@ -343,7 +343,7 @@ class _HomePageState extends State<HomePage>
|
||||
}
|
||||
updateHomeWidget();
|
||||
await GetIt.I.allReady();
|
||||
await Providers.server.loadLocalData();
|
||||
await Providers.server.load();
|
||||
await Providers.server.refreshData();
|
||||
if (!Analysis.enabled) {
|
||||
Analysis.init();
|
||||
|
||||
@@ -456,7 +456,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
await GetIt.I.allReady();
|
||||
await Providers.server.loadLocalData();
|
||||
await Providers.server.load();
|
||||
Providers.server.startAutoRefresh();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user