Settings: move things to UpdateService & cleanup

This commit is contained in:
Ly-sec
2025-11-18 00:58:57 +01:00
parent 8034297fb7
commit 836029b567
2 changed files with 26 additions and 28 deletions
+5 -15
View File
@@ -17,9 +17,6 @@ Singleton {
property bool directoriesCreated: false
property int settingsVersion: 23
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
property bool changelogPending: false
property string changelogFromVersion: ""
property string changelogToVersion: ""
// Define our app directories
// Default config directory: ~/.config/noctalia
@@ -40,7 +37,6 @@ Singleton {
// Signal emitted when settings are loaded after startupcale changes
signal settingsLoaded
signal settingsSaved
signal changelogTriggered(string previousVersion, string currentVersion)
// -----------------------------------------------------
// -----------------------------------------------------
@@ -553,11 +549,11 @@ Singleton {
const versionChanged = storedVersion !== currentVersion;
const shouldTrigger = forceShow || (hasSeenBefore && versionChanged);
if (shouldTrigger) {
changelogFromVersion = storedVersion;
changelogToVersion = currentVersion;
changelogPending = true;
root.changelogTriggered(storedVersion, currentVersion);
if (shouldTrigger && UpdateService) {
UpdateService.changelogFromVersion = storedVersion;
UpdateService.changelogToVersion = currentVersion;
UpdateService.changelogPending = true;
UpdateService.handleChangelogRequest();
}
adapter.changelog.lastSeenVersion = currentVersion;
@@ -568,12 +564,6 @@ Singleton {
}
}
function clearChangelogRequest() {
changelogPending = false;
changelogFromVersion = "";
changelogToVersion = "";
}
// -----------------------------------------------------
// Function to preprocess paths by expanding "~" to user's home directory
function preprocessPath(path) {
+21 -13
View File
@@ -16,6 +16,9 @@ Singleton {
// Changelog properties
property bool initialized: false
property bool changelogPending: false
property string changelogFromVersion: ""
property string changelogToVersion: ""
property string previousVersion: ""
property string changelogCurrentVersion: ""
property var releaseHighlights: []
@@ -45,15 +48,8 @@ Singleton {
initialized = true;
Logger.i("UpdateService", "Version:", root.currentVersion);
if (Settings.changelogPending) {
handleChangelogRequest(Settings.changelogFromVersion, Settings.changelogToVersion);
}
}
Connections {
target: Settings ? Settings : null
function onChangelogTriggered(fromVersion, toVersion) {
handleChangelogRequest(fromVersion, toVersion);
if (changelogPending) {
handleChangelogRequest(changelogFromVersion, changelogToVersion);
}
}
@@ -70,7 +66,10 @@ Singleton {
}
}
function handleChangelogRequest(fromVersion, toVersion) {
function handleChangelogRequest() {
const fromVersion = changelogFromVersion || "";
const toVersion = changelogToVersion || "";
if (!toVersion)
return;
@@ -80,7 +79,7 @@ Singleton {
if (!popupScheduled && lastShownVersion === toVersion)
return;
previousVersion = fromVersion || "";
previousVersion = fromVersion;
changelogCurrentVersion = toVersion;
fetchError = GitHubService ? GitHubService.releaseFetchError : "";
releaseHighlights = buildReleaseHighlights(previousVersion, changelogCurrentVersion);
@@ -89,7 +88,7 @@ Singleton {
popupScheduled = true;
root.popupQueued(previousVersion, changelogCurrentVersion);
Settings.clearChangelogRequest();
clearChangelogRequest();
openWhenReady();
}
@@ -305,6 +304,15 @@ Singleton {
function showLatestChangelog() {
if (!currentVersion)
return;
handleChangelogRequest(Settings.data.changelog.lastSeenVersion, currentVersion);
changelogFromVersion = Settings.data.changelog.lastSeenVersion || "";
changelogToVersion = currentVersion;
changelogPending = true;
handleChangelogRequest();
}
function clearChangelogRequest() {
changelogPending = false;
changelogFromVersion = "";
changelogToVersion = "";
}
}