summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2026-04-06 16:57:58 +0200
committerxengineering <me@xengineering.eu>2026-04-06 16:57:58 +0200
commitfcfb2a17733a38b690f4e034c78bc414be5527ef (patch)
tree92932f23c5b1d2798a9e63467b0ad4de70caa39f /lib
parent34d52bf961071348d8262e6d08d1703530ff8556 (diff)
downloadsia-app-fcfb2a17733a38b690f4e034c78bc414be5527ef.tar
sia-app-fcfb2a17733a38b690f4e034c78bc414be5527ef.tar.zst
sia-app-fcfb2a17733a38b690f4e034c78bc414be5527ef.zip
Implement setting server_fqdn
This persists the used server_fqdn on connection. This makes sure the user does not need to specify the FQDN every time.
Diffstat (limited to 'lib')
-rw-r--r--lib/data.dart1
-rw-r--r--lib/db.dart18
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/data.dart b/lib/data.dart
index e4d7524..ca350e5 100644
--- a/lib/data.dart
+++ b/lib/data.dart
@@ -70,6 +70,7 @@ class AppState with ChangeNotifier {
void setFqdn(String value) {
fqdn = value;
+ unawaited(db.setServerFqdn(value));
}
void process(MachineEvent event) {
diff --git a/lib/db.dart b/lib/db.dart
index a39db1d..0b2cf7a 100644
--- a/lib/db.dart
+++ b/lib/db.dart
@@ -69,4 +69,22 @@ CREATE TABLE "key_value" (
return result[0]['value'];
}
+
+ Future<void> setServerFqdn(String value) async {
+ Database? db = await _dbCompleter.future;
+ if (db == null) return;
+
+ String? current = await getServerFqdn();
+ if (current == null) {
+ db.execute(
+ 'INSERT INTO key_value (key, value) VALUES (\'server_fqdn\', ?);',
+ <Object?>[value],
+ );
+ } else {
+ db.execute(
+ 'UPDATE key_value SET value = ? WHERE key = \'server_fqdn\';',
+ <Object?>[value],
+ );
+ }
+ }
}