Skip to content

Commit

Permalink
Fix first time config
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Feb 23, 2024
1 parent d46ad3e commit 010577e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ class Config {
static void init() {
signal.value = readConfig();
signals.effect(() {
print('Config changed: ${signal.value}');
debugPrint('Config changed: ${signal.value}');
writeConfig(signal.value);
});
}

static ConfigData readConfig() {
ensureConfigExists();
var configData = configFile.readAsStringSync();
print('Read config: $configData');
debugPrint('Read config: $configData');
return ConfigData.fromJson(jsonDecode(configData));
}

Expand All @@ -103,10 +103,10 @@ class Config {

static void ensureConfigExists() {
if (!configDir.existsSync()) {
configDir.createSync();
configDir.createSync(recursive: true);
}
if (!configFile.existsSync()) {
configFile.writeAsStringSync('{}');
if (!configFile.existsSync() || configFile.lengthSync() == 0) {
configFile.writeAsStringSync('{}', flush: true);
}
}

Expand Down

0 comments on commit 010577e

Please sign in to comment.