mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-15 04:34:34 +01:00
opt.
This commit is contained in:
@@ -5,28 +5,29 @@ import 'package:toolbox/locator.dart';
|
||||
|
||||
class PrivateKeyProvider extends BusyProvider {
|
||||
List<PrivateKeyInfo> get infos => _infos;
|
||||
final _store = locator<PrivateKeyStore>();
|
||||
late List<PrivateKeyInfo> _infos;
|
||||
|
||||
void loadData() {
|
||||
_infos = locator<PrivateKeyStore>().fetch();
|
||||
_infos = _store.fetch();
|
||||
}
|
||||
|
||||
void addInfo(PrivateKeyInfo info) {
|
||||
_infos.add(info);
|
||||
locator<PrivateKeyStore>().put(info);
|
||||
_store.put(info);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void delInfo(PrivateKeyInfo info) {
|
||||
_infos.removeWhere((e) => e.id == info.id);
|
||||
locator<PrivateKeyStore>().delete(info);
|
||||
_store.delete(info);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void updateInfo(PrivateKeyInfo old, PrivateKeyInfo newInfo) {
|
||||
final idx = _infos.indexWhere((e) => e.id == old.id);
|
||||
_infos[idx] = newInfo;
|
||||
locator<PrivateKeyStore>().put(newInfo);
|
||||
_store.put(newInfo);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,15 +22,18 @@ typedef ServersMap = Map<String, Server>;
|
||||
class ServerProvider extends BusyProvider {
|
||||
final ServersMap _servers = {};
|
||||
ServersMap get servers => _servers;
|
||||
|
||||
final _limiter = TryLimiter();
|
||||
|
||||
Timer? _timer;
|
||||
|
||||
final _logger = Logger('SERVER');
|
||||
|
||||
final _store = locator<ServerStore>();
|
||||
|
||||
Future<void> loadLocalData() async {
|
||||
setBusyState(true);
|
||||
final infos = locator<ServerStore>().fetch();
|
||||
final infos = _store.fetch();
|
||||
for (final info in infos) {
|
||||
_servers[info.id] = genServer(info);
|
||||
}
|
||||
@@ -103,20 +106,20 @@ class ServerProvider extends BusyProvider {
|
||||
void addServer(ServerPrivateInfo spi) {
|
||||
_servers[spi.id] = genServer(spi);
|
||||
notifyListeners();
|
||||
locator<ServerStore>().put(spi);
|
||||
_store.put(spi);
|
||||
refreshData(spi: spi);
|
||||
}
|
||||
|
||||
void delServer(String id) {
|
||||
_servers.remove(id);
|
||||
notifyListeners();
|
||||
locator<ServerStore>().delete(id);
|
||||
_store.delete(id);
|
||||
}
|
||||
|
||||
Future<void> updateServer(
|
||||
ServerPrivateInfo old, ServerPrivateInfo newSpi) async {
|
||||
_servers.remove(old.id);
|
||||
locator<ServerStore>().update(old, newSpi);
|
||||
_store.update(old, newSpi);
|
||||
_servers[newSpi.id] = genServer(newSpi);
|
||||
_servers[newSpi.id]?.client = await genClient(newSpi);
|
||||
notifyListeners();
|
||||
|
||||
@@ -7,23 +7,24 @@ import 'package:toolbox/locator.dart';
|
||||
|
||||
class SnippetProvider extends BusyProvider {
|
||||
List<Snippet> get snippets => _snippets;
|
||||
final _store = locator<SnippetStore>();
|
||||
late List<Snippet> _snippets;
|
||||
|
||||
void loadData() {
|
||||
_snippets = locator<SnippetStore>().fetch();
|
||||
_snippets = _store.fetch();
|
||||
}
|
||||
|
||||
void add(Snippet snippet) {
|
||||
if (have(snippet)) return;
|
||||
_snippets.add(snippet);
|
||||
locator<SnippetStore>().put(snippet);
|
||||
_store.put(snippet);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void del(Snippet snippet) {
|
||||
if (!have(snippet)) return;
|
||||
_snippets.removeAt(index(snippet));
|
||||
locator<SnippetStore>().delete(snippet);
|
||||
_store.delete(snippet);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -38,7 +39,7 @@ class SnippetProvider extends BusyProvider {
|
||||
void update(Snippet old, Snippet newOne) {
|
||||
if (!have(old)) return;
|
||||
_snippets[index(old)] = newOne;
|
||||
locator<SnippetStore>().put(newOne);
|
||||
_store.put(newOne);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 287;
|
||||
static const int build = 288;
|
||||
static const String engine = "3.7.11";
|
||||
static const String buildAt = "2023-05-07 18:25:45.312302";
|
||||
static const int modifications = 2;
|
||||
static const String buildAt = "2023-05-07 20:47:03.124092";
|
||||
static const int modifications = 1;
|
||||
}
|
||||
|
||||
@@ -33,3 +33,15 @@ const popMenuChild = Padding(
|
||||
size: 21,
|
||||
),
|
||||
);
|
||||
|
||||
const centerLoading = Center(child: CircularProgressIndicator());
|
||||
|
||||
const centerSizedLoading = SizedBox(
|
||||
width: 77,
|
||||
height: 77,
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
|
||||
const loadingIcon = IconButton(onPressed: null, icon: centerLoading);
|
||||
|
||||
@@ -6,6 +6,7 @@ const issueUrl = '$myGithub/flutter_server_box/issues';
|
||||
|
||||
// Thanks
|
||||
const thanksMap = {
|
||||
'its-tom': 'https://github.com/its-tom',
|
||||
'RainSunMe': 'https://github.com/RainSunMe',
|
||||
'fecture': 'https://github.com/fecture',
|
||||
'Tao173': 'https://github.com/Tao173',
|
||||
|
||||
Reference in New Issue
Block a user