refactors (#539)

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-16 01:24:43 +08:00
committed by GitHub
parent 7e5bb54c98
commit 38366a2ef3
45 changed files with 527 additions and 640 deletions

View File

@@ -5,17 +5,17 @@ import 'package:server_box/data/model/server/server_private_info.dart';
class ServerStore extends PersistentStore {
ServerStore() : super('server');
void put(ServerPrivateInfo info) {
void put(Spi info) {
box.put(info.id, info);
box.updateLastModified();
}
List<ServerPrivateInfo> fetch() {
List<Spi> fetch() {
final ids = box.keys;
final List<ServerPrivateInfo> ss = [];
final List<Spi> ss = [];
for (final id in ids) {
final s = box.get(id);
if (s != null && s is ServerPrivateInfo) {
if (s != null && s is Spi) {
ss.add(s);
}
}
@@ -32,7 +32,7 @@ class ServerStore extends PersistentStore {
box.updateLastModified();
}
void update(ServerPrivateInfo old, ServerPrivateInfo newInfo) {
void update(Spi old, Spi newInfo) {
if (!have(old)) {
throw Exception('Old spi: $old not found');
}
@@ -40,5 +40,5 @@ class ServerStore extends PersistentStore {
put(newInfo);
}
bool have(ServerPrivateInfo s) => box.get(s.id) != null;
bool have(Spi s) => box.get(s.id) != null;
}