mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
settings: detect read-only on save attempts
This commit is contained in:
@@ -127,11 +127,19 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _onWritableCheckComplete(writable) {
|
function _onWritableCheckComplete(writable) {
|
||||||
|
const wasReadOnly = _isReadOnly;
|
||||||
_isReadOnly = !writable;
|
_isReadOnly = !writable;
|
||||||
if (_isReadOnly) {
|
if (_isReadOnly) {
|
||||||
console.info("SessionData: session.json is read-only (NixOS home-manager mode)");
|
_hasUnsavedChanges = _checkForUnsavedChanges();
|
||||||
} else if (_pendingMigration) {
|
if (!wasReadOnly)
|
||||||
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
|
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;
|
_pendingMigration = null;
|
||||||
}
|
}
|
||||||
@@ -215,11 +223,9 @@ Singleton {
|
|||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
if (isGreeterMode || _parseError || !_hasLoaded)
|
if (isGreeterMode || _parseError || !_hasLoaded)
|
||||||
return;
|
return;
|
||||||
if (_isReadOnly) {
|
|
||||||
_hasUnsavedChanges = _checkForUnsavedChanges();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
settingsFile.setText(getCurrentSessionJson());
|
settingsFile.setText(getCurrentSessionJson());
|
||||||
|
if (_isReadOnly)
|
||||||
|
_checkSessionWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function migrateFromUndefinedToV1(settings) {
|
function migrateFromUndefinedToV1(settings) {
|
||||||
@@ -953,6 +959,10 @@ Singleton {
|
|||||||
parseSettings(settingsFile.text());
|
parseSettings(settingsFile.text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onSaveFailed: error => {
|
||||||
|
root._isReadOnly = true;
|
||||||
|
root._hasUnsavedChanges = root._checkForUnsavedChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|||||||
@@ -840,11 +840,19 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _onWritableCheckComplete(writable) {
|
function _onWritableCheckComplete(writable) {
|
||||||
|
const wasReadOnly = _isReadOnly;
|
||||||
_isReadOnly = !writable;
|
_isReadOnly = !writable;
|
||||||
if (_isReadOnly) {
|
if (_isReadOnly) {
|
||||||
console.info("SettingsData: settings.json is read-only (NixOS home-manager mode)");
|
_hasUnsavedChanges = _checkForUnsavedChanges();
|
||||||
} else if (_pendingMigration) {
|
if (!wasReadOnly)
|
||||||
settingsFile.setText(JSON.stringify(_pendingMigration, null, 2));
|
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;
|
_pendingMigration = null;
|
||||||
}
|
}
|
||||||
@@ -889,11 +897,9 @@ Singleton {
|
|||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
if (_loading || _parseError || !_hasLoaded)
|
if (_loading || _parseError || !_hasLoaded)
|
||||||
return;
|
return;
|
||||||
if (_isReadOnly) {
|
|
||||||
_hasUnsavedChanges = _checkForUnsavedChanges();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
|
settingsFile.setText(JSON.stringify(Store.toJson(root), null, 2));
|
||||||
|
if (_isReadOnly)
|
||||||
|
_checkSettingsWritable();
|
||||||
}
|
}
|
||||||
|
|
||||||
function savePluginSettings() {
|
function savePluginSettings() {
|
||||||
@@ -1889,6 +1895,10 @@ Singleton {
|
|||||||
applyStoredTheme();
|
applyStoredTheme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onSaveFailed: error => {
|
||||||
|
root._isReadOnly = true;
|
||||||
|
root._hasUnsavedChanges = root._checkForUnsavedChanges();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|||||||
Reference in New Issue
Block a user