1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

settings: detect read-only on save attempts

This commit is contained in:
bbedward
2026-01-03 20:34:36 -05:00
parent aa72eacae7
commit 436c99927e
2 changed files with 34 additions and 14 deletions

View File

@@ -127,11 +127,19 @@ Singleton {
}
function _onWritableCheckComplete(writable) {
const wasReadOnly = _isReadOnly;
_isReadOnly = !writable;
if (_isReadOnly) {
console.info("SessionData: session.json is read-only (NixOS home-manager mode)");
} else if (_pendingMigration) {
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
_hasUnsavedChanges = _checkForUnsavedChanges();
if (!wasReadOnly)
console.info("SessionData: session.json is now read-only");
} else {
_loadedSessionSnapshot = getCurrentSessionJson();
_hasUnsavedChanges = false;
if (wasReadOnly)
console.info("SessionData: session.json is now writable");
if (_pendingMigration)
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
}
_pendingMigration = null;
}
@@ -215,11 +223,9 @@ Singleton {
function saveSettings() {
if (isGreeterMode || _parseError || !_hasLoaded)
return;
if (_isReadOnly) {
_hasUnsavedChanges = _checkForUnsavedChanges();
return;
}
settingsFile.setText(getCurrentSessionJson());
if (_isReadOnly)
_checkSessionWritable();
}
function migrateFromUndefinedToV1(settings) {
@@ -953,6 +959,10 @@ Singleton {
parseSettings(settingsFile.text());
}
}
onSaveFailed: error => {
root._isReadOnly = true;
root._hasUnsavedChanges = root._checkForUnsavedChanges();
}
}
FileView {

View File

@@ -840,11 +840,19 @@ Singleton {
}
function _onWritableCheckComplete(writable) {
const wasReadOnly = _isReadOnly;
_isReadOnly = !writable;
if (_isReadOnly) {
console.info("SettingsData: settings.json is read-only (NixOS home-manager mode)");
} else if (_pendingMigration) {
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
_hasUnsavedChanges = _checkForUnsavedChanges();
if (!wasReadOnly)
console.info("SettingsData: settings.json is now read-only");
} else {
_loadedSettingsSnapshot = JSON.stringify(Store.toJson(root));
_hasUnsavedChanges = false;
if (wasReadOnly)
console.info("SettingsData: settings.json is now writable");
if (_pendingMigration)
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
}
_pendingMigration = null;
}
@@ -889,11 +897,9 @@ Singleton {
function saveSettings() {
if (_loading || _parseError || !_hasLoaded)
return;
if (_isReadOnly) {
_hasUnsavedChanges = _checkForUnsavedChanges();
return;
}
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
if (_isReadOnly)
_checkSettingsWritable();
}
function savePluginSettings() {
@@ -1889,6 +1895,10 @@ Singleton {
applyStoredTheme();
}
}
onSaveFailed: error => {
root._isReadOnly = true;
root._hasUnsavedChanges = root._checkForUnsavedChanges();
}
}
FileView {