diff --git a/lib/data/model/app/backup.dart b/lib/data/model/app/backup.dart index f828a8334..623534ce1 100644 --- a/lib/data/model/app/backup.dart +++ b/lib/data/model/app/backup.dart @@ -7,7 +7,6 @@ import 'package:logging/logging.dart'; import 'package:server_box/data/model/server/private_key_info.dart'; import 'package:server_box/data/model/server/server_private_info.dart'; import 'package:server_box/data/model/server/snippet.dart'; -import 'package:server_box/data/provider/base.dart'; import 'package:server_box/data/res/misc.dart'; import 'package:server_box/data/res/rebuild.dart'; import 'package:server_box/data/res/store.dart'; diff --git a/lib/data/provider/base.dart b/lib/data/provider/base.dart deleted file mode 100644 index 05116018f..000000000 --- a/lib/data/provider/base.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/foundation.dart'; - -abstract class Provider { - const Provider(); - - /// (Re)Load data from store / network / etc. - @mustCallSuper - FutureOr load() { - all.add(this); - debugPrint('$runtimeType added'); - } - - static final all = []; - - static Future reload() { - return Future.wait(all.map((e) async => await e.load())); - } -} diff --git a/lib/data/provider/private_key.dart b/lib/data/provider/private_key.dart index 58ca691c1..3015c063a 100644 --- a/lib/data/provider/private_key.dart +++ b/lib/data/provider/private_key.dart @@ -1,6 +1,5 @@ import 'package:fl_lib/fl_lib.dart'; import 'package:server_box/data/model/server/private_key_info.dart'; -import 'package:server_box/data/provider/base.dart'; import 'package:server_box/data/res/store.dart'; class PrivateKeyProvider extends Provider { @@ -31,10 +30,12 @@ class PrivateKeyProvider extends Provider { final idx = pkis.value.indexWhere((e) => e.id == old.id); if (idx == -1) { pkis.value.add(newInfo); + Stores.key.put(newInfo); + Stores.key.delete(old); } else { pkis.value[idx] = newInfo; + Stores.key.put(newInfo); } pkis.notify(); - Stores.key.put(newInfo); } } diff --git a/lib/data/provider/server.dart b/lib/data/provider/server.dart index acdfbfed8..9c4c2775a 100644 --- a/lib/data/provider/server.dart +++ b/lib/data/provider/server.dart @@ -9,9 +9,6 @@ import 'package:server_box/core/utils/ssh_auth.dart'; import 'package:server_box/data/model/app/error.dart'; import 'package:server_box/data/model/app/shell_func.dart'; import 'package:server_box/data/model/server/system.dart'; -import 'package:server_box/data/provider/base.dart'; -// import 'package:server_box/data/model/sftp/req.dart'; -// import 'package:server_box/data/res/provider.dart'; import 'package:server_box/data/res/store.dart'; import 'package:server_box/core/utils/server.dart'; diff --git a/lib/data/provider/sftp.dart b/lib/data/provider/sftp.dart index 7f6f4ce51..8943289b3 100644 --- a/lib/data/provider/sftp.dart +++ b/lib/data/provider/sftp.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:fl_lib/fl_lib.dart'; import 'package:server_box/data/model/sftp/worker.dart'; -import 'package:server_box/data/provider/base.dart'; class SftpProvider extends Provider { const SftpProvider._(); diff --git a/lib/data/provider/snippet.dart b/lib/data/provider/snippet.dart index a4c49019b..373805c37 100644 --- a/lib/data/provider/snippet.dart +++ b/lib/data/provider/snippet.dart @@ -1,6 +1,5 @@ import 'package:fl_lib/fl_lib.dart'; import 'package:server_box/data/model/server/snippet.dart'; -import 'package:server_box/data/provider/base.dart'; import 'package:server_box/data/res/store.dart'; class SnippetProvider extends Provider { diff --git a/lib/view/page/private_key/edit.dart b/lib/view/page/private_key/edit.dart index 1bce62a5d..a29180851 100644 --- a/lib/view/page/private_key/edit.dart +++ b/lib/view/page/private_key/edit.dart @@ -203,8 +203,9 @@ class _PrivateKeyEditPageState extends State { try { final decrypted = await Computer.shared.start(decyptPem, [key, pwd]); final pki = PrivateKeyInfo(id: name, key: decrypted); - if (widget.pki != null) { - PrivateKeyProvider.update(widget.pki!, pki); + final originPki = widget.pki; + if (originPki != null) { + PrivateKeyProvider.update(originPki, pki); } else { PrivateKeyProvider.add(pki); } diff --git a/pubspec.lock b/pubspec.lock index f572e12c6..f64f8395d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -389,9 +389,11 @@ packages: fl_lib: dependency: "direct main" description: - path: "../fl_lib" - relative: true - source: path + path: "." + ref: "v1.0.141" + resolved-ref: "2fb1532cd2fd08dd807e9776b2b50b5d8ee94388" + url: "https://github.com/lppcg/fl_lib" + source: git version: "0.0.1" flutter: dependency: "direct main" diff --git a/pubspec.yaml b/pubspec.yaml index 0ddd8b86f..44c884663 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -60,7 +60,7 @@ dependencies: fl_lib: git: url: https://github.com/lppcg/fl_lib - ref: v1.0.140 + ref: v1.0.141 dependency_overrides: # dartssh2: