mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
session: fix persist on empty file
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -108,3 +108,4 @@ bin/
|
|||||||
# direnv
|
# direnv
|
||||||
.envrc
|
.envrc
|
||||||
.direnv/
|
.direnv/
|
||||||
|
quickshell/dms-plugins
|
||||||
|
|||||||
@@ -158,12 +158,7 @@ Singleton {
|
|||||||
function parseSettings(content) {
|
function parseSettings(content) {
|
||||||
_parseError = false;
|
_parseError = false;
|
||||||
try {
|
try {
|
||||||
if (!content || !content.trim()) {
|
let obj = (content && content.trim()) ? JSON.parse(content) : {};
|
||||||
_parseError = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let obj = JSON.parse(content);
|
|
||||||
|
|
||||||
if (obj.brightnessLogarithmicDevices && !obj.brightnessExponentialDevices) {
|
if (obj.brightnessLogarithmicDevices && !obj.brightnessExponentialDevices) {
|
||||||
obj.brightnessExponentialDevices = obj.brightnessLogarithmicDevices;
|
obj.brightnessExponentialDevices = obj.brightnessLogarithmicDevices;
|
||||||
|
|||||||
@@ -89,6 +89,8 @@ Singleton {
|
|||||||
property bool qtThemingEnabled: typeof SettingsData !== "undefined" ? (SettingsData.qt5ctAvailable || SettingsData.qt6ctAvailable) : false
|
property bool qtThemingEnabled: typeof SettingsData !== "undefined" ? (SettingsData.qt5ctAvailable || SettingsData.qt6ctAvailable) : false
|
||||||
property var workerRunning: false
|
property var workerRunning: false
|
||||||
property var pendingThemeRequest: null
|
property var pendingThemeRequest: null
|
||||||
|
|
||||||
|
signal matugenCompleted(string mode, string result)
|
||||||
property var matugenColors: ({})
|
property var matugenColors: ({})
|
||||||
property var _pendingGenerateParams: null
|
property var _pendingGenerateParams: null
|
||||||
|
|
||||||
@@ -1272,24 +1274,32 @@ Singleton {
|
|||||||
|
|
||||||
onExited: exitCode => {
|
onExited: exitCode => {
|
||||||
workerRunning = false;
|
workerRunning = false;
|
||||||
|
const currentMode = (typeof SessionData !== "undefined" && SessionData.isLightMode) ? "light" : "dark";
|
||||||
|
|
||||||
if (exitCode === 0) {
|
switch (exitCode) {
|
||||||
|
case 0:
|
||||||
console.info("Theme: Matugen worker completed successfully");
|
console.info("Theme: Matugen worker completed successfully");
|
||||||
} else if (exitCode === 2) {
|
root.matugenCompleted(currentMode, "success");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
console.log("Theme: Matugen worker completed with code 2 (no changes needed)");
|
console.log("Theme: Matugen worker completed with code 2 (no changes needed)");
|
||||||
} else {
|
root.matugenCompleted(currentMode, "no-changes");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
if (typeof ToastService !== "undefined") {
|
if (typeof ToastService !== "undefined") {
|
||||||
ToastService.showError("Theme worker failed (" + exitCode + ")");
|
ToastService.showError("Theme worker failed (" + exitCode + ")");
|
||||||
}
|
}
|
||||||
console.warn("Theme: Matugen worker failed with exit code:", exitCode);
|
console.warn("Theme: Matugen worker failed with exit code:", exitCode);
|
||||||
|
root.matugenCompleted(currentMode, "error");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pendingThemeRequest) {
|
if (!pendingThemeRequest)
|
||||||
const req = pendingThemeRequest;
|
return;
|
||||||
pendingThemeRequest = null;
|
|
||||||
console.info("Theme: Processing queued theme request");
|
const req = pendingThemeRequest;
|
||||||
setDesiredTheme(req.kind, req.value, req.isLight, req.iconTheme, req.matugenType, req.stockColors);
|
pendingThemeRequest = null;
|
||||||
}
|
console.info("Theme: Processing queued theme request");
|
||||||
|
setDesiredTheme(req.kind, req.value, req.isLight, req.iconTheme, req.matugenType, req.stockColors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user