mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2025-12-06 06:36:15 +00:00
Changelog: remove changelogs.json
This commit is contained in:
@@ -222,9 +222,6 @@ SmartPanel {
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
if (UpdateService && UpdateService.clearReleaseCache) {
|
||||
UpdateService.clearReleaseCache();
|
||||
}
|
||||
if (UpdateService && UpdateService.changelogCurrentVersion) {
|
||||
UpdateService.markChangelogSeen(UpdateService.changelogCurrentVersion);
|
||||
}
|
||||
|
||||
@@ -37,12 +37,6 @@ Singleton {
|
||||
// Changelog fetching
|
||||
property string changelogBaseUrl: Quickshell.env("NOCTALIA_CHANGELOG_URL") || "https://noctalia.dev:7777/changelogs"
|
||||
property string upgradeLogBaseUrl: Quickshell.env("NOCTALIA_UPGRADELOG_URL") || "https://noctalia.dev:7777/upgradelog"
|
||||
property int changelogFetchLimit: 25
|
||||
property int changelogUpdateFrequency: 60 * 60 // 1 hour in seconds
|
||||
property bool isFetchingChangelogs: false
|
||||
property string releaseNotes: ""
|
||||
property var releases: []
|
||||
property string changelogDataFile: Quickshell.env("NOCTALIA_CHANGELOG_FILE") || (Settings.cacheDir + "changelogs.json")
|
||||
|
||||
// Fix for FileView race condition
|
||||
property bool saveInProgress: false
|
||||
@@ -69,36 +63,6 @@ Singleton {
|
||||
Logger.i("UpdateService", "Version:", root.currentVersion);
|
||||
}
|
||||
|
||||
// Changelog data cache
|
||||
FileView {
|
||||
id: changelogDataFileView
|
||||
path: root.changelogDataFile
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
onAdapterUpdated: writeAdapter()
|
||||
Component.onCompleted: {
|
||||
reload();
|
||||
}
|
||||
onLoaded: {
|
||||
loadChangelogCache();
|
||||
}
|
||||
onLoadFailed: function (error) {
|
||||
if (error.toString().includes("No such file") || error === 2) {
|
||||
Qt.callLater(() => {
|
||||
fetchChangelogs();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
JsonAdapter {
|
||||
id: changelogAdapter
|
||||
|
||||
property string releaseNotes: ""
|
||||
property var releases: []
|
||||
property real timestamp: 0
|
||||
}
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: changelogStateFileView
|
||||
path: root.changelogStateFile
|
||||
@@ -450,201 +414,5 @@ Singleton {
|
||||
debouncedSaveChangelogState();
|
||||
}
|
||||
|
||||
// Changelog fetching functions
|
||||
|
||||
function loadChangelogCache() {
|
||||
const now = Time.timestamp;
|
||||
var needsRefetch = false;
|
||||
if (!changelogAdapter.timestamp || (now >= changelogAdapter.timestamp + changelogUpdateFrequency)) {
|
||||
needsRefetch = true;
|
||||
Logger.d("UpdateService", "Changelog cache expired or missing, scheduling fetch");
|
||||
} else {
|
||||
Logger.d("UpdateService", "Loading cached changelog data (age:", Math.round((now - changelogAdapter.timestamp) / 60), "minutes)");
|
||||
}
|
||||
|
||||
if (changelogAdapter.releaseNotes) {
|
||||
root.releaseNotes = changelogAdapter.releaseNotes;
|
||||
}
|
||||
if (changelogAdapter.releases && changelogAdapter.releases.length > 0) {
|
||||
root.releases = changelogAdapter.releases;
|
||||
} else {
|
||||
Logger.d("UpdateService", "Cached releases missing, scheduling fetch");
|
||||
needsRefetch = true;
|
||||
}
|
||||
|
||||
if (needsRefetch) {
|
||||
fetchChangelogs();
|
||||
}
|
||||
}
|
||||
|
||||
function fetchChangelogs() {
|
||||
if (isFetchingChangelogs) {
|
||||
Logger.w("UpdateService", "Changelog data is still fetching");
|
||||
return;
|
||||
}
|
||||
|
||||
isFetchingChangelogs = true;
|
||||
fetchError = "";
|
||||
fetchChangelogIndex();
|
||||
}
|
||||
|
||||
function fetchChangelogIndex() {
|
||||
const request = new XMLHttpRequest();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === XMLHttpRequest.DONE) {
|
||||
if (request.status >= 200 && request.status < 300) {
|
||||
const entries = parseChangelogIndex(request.responseText || "");
|
||||
if (entries.length === 0) {
|
||||
Logger.w("UpdateService", "No changelog entries found at", changelogBaseUrl);
|
||||
fetchError = I18n.tr("changelog.error.fetch-failed");
|
||||
finalizeChangelogFetch([]);
|
||||
} else {
|
||||
fetchChangelogFiles(entries, 0, []);
|
||||
}
|
||||
} else {
|
||||
Logger.e("UpdateService", "Failed to fetch changelog index:", request.status, request.responseText);
|
||||
fetchError = I18n.tr("changelog.error.fetch-failed");
|
||||
finalizeChangelogFetch([]);
|
||||
}
|
||||
}
|
||||
};
|
||||
request.open("GET", changelogBaseUrl);
|
||||
request.send();
|
||||
}
|
||||
|
||||
function parseChangelogIndex(content) {
|
||||
if (!content)
|
||||
return [];
|
||||
|
||||
const lines = content.split(/\r?\n/);
|
||||
var entries = [];
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
const trimmed = lines[i].trim();
|
||||
const match = trimmed.match(/CHANGELOG-(v[0-9A-Za-z.\-]+)\.txt/);
|
||||
if (match && match.length >= 2) {
|
||||
const version = match[1];
|
||||
const fileName = match[0];
|
||||
var modified = "";
|
||||
for (var j = i + 1; j < Math.min(lines.length, i + 4); j++) {
|
||||
const modLine = lines[j].trim();
|
||||
const modMatch = modLine.match(/^Last modified:\s*(.+)$/i);
|
||||
if (modMatch && modMatch.length >= 2) {
|
||||
modified = modMatch[1].trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
entries.push({
|
||||
"version": version,
|
||||
"fileName": fileName,
|
||||
"url": `${changelogBaseUrl}/${fileName}`,
|
||||
"createdAt": modified
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
entries.sort(function (a, b) {
|
||||
return compareVersions(b.version, a.version);
|
||||
});
|
||||
|
||||
if (entries.length > changelogFetchLimit) {
|
||||
entries = entries.slice(0, changelogFetchLimit);
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
function fetchChangelogFiles(entries, index, accumulator) {
|
||||
if (!entries || entries.length === 0) {
|
||||
finalizeChangelogFetch([]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= entries.length) {
|
||||
finalizeChangelogFetch(accumulator);
|
||||
return;
|
||||
}
|
||||
|
||||
const entry = entries[index];
|
||||
const request = new XMLHttpRequest();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === XMLHttpRequest.DONE) {
|
||||
if (request.status >= 200 && request.status < 300) {
|
||||
accumulator.push({
|
||||
"version": entry.version,
|
||||
"createdAt": entry.createdAt || "",
|
||||
"body": request.responseText || ""
|
||||
});
|
||||
} else {
|
||||
Logger.e("UpdateService", "Failed to fetch changelog file:", entry.url, "status:", request.status);
|
||||
if (!fetchError) {
|
||||
fetchError = I18n.tr("changelog.error.fetch-failed");
|
||||
}
|
||||
}
|
||||
fetchChangelogFiles(entries, index + 1, accumulator);
|
||||
}
|
||||
};
|
||||
request.open("GET", entry.url);
|
||||
request.send();
|
||||
}
|
||||
|
||||
function finalizeChangelogFetch(releasesList) {
|
||||
isFetchingChangelogs = false;
|
||||
|
||||
if (releasesList && releasesList.length > 0) {
|
||||
releasesList.sort(function (a, b) {
|
||||
return compareVersions(b.version, a.version);
|
||||
});
|
||||
|
||||
changelogAdapter.releases = releasesList;
|
||||
root.releases = releasesList;
|
||||
const latest = releasesList[0];
|
||||
if (latest) {
|
||||
changelogAdapter.releaseNotes = latest.body || "";
|
||||
root.releaseNotes = changelogAdapter.releaseNotes;
|
||||
}
|
||||
|
||||
if (!fetchError) {
|
||||
Logger.d("UpdateService", "Fetched changelog entries:", releasesList.length);
|
||||
}
|
||||
} else {
|
||||
changelogAdapter.releases = [];
|
||||
root.releases = [];
|
||||
if (!fetchError) {
|
||||
Logger.w("UpdateService", "No changelog entries fetched");
|
||||
fetchError = I18n.tr("changelog.error.fetch-failed");
|
||||
}
|
||||
}
|
||||
|
||||
saveChangelogData();
|
||||
}
|
||||
|
||||
function saveChangelogData() {
|
||||
changelogAdapter.timestamp = Time.timestamp;
|
||||
Logger.d("UpdateService", "Saving changelog data to cache file:", changelogDataFile);
|
||||
|
||||
// Ensure cache directory exists
|
||||
Quickshell.execDetached(["mkdir", "-p", Settings.cacheDir]);
|
||||
|
||||
Qt.callLater(() => {
|
||||
changelogDataFileView.writeAdapter();
|
||||
Logger.d("UpdateService", "Changelog cache file written successfully");
|
||||
});
|
||||
}
|
||||
|
||||
function resetChangelogCache() {
|
||||
changelogAdapter.version = I18n.tr("system.unknown-version");
|
||||
changelogAdapter.releaseNotes = "";
|
||||
changelogAdapter.releases = [];
|
||||
changelogAdapter.timestamp = 0;
|
||||
|
||||
fetchChangelogs();
|
||||
}
|
||||
|
||||
function clearReleaseCache() {
|
||||
Logger.d("UpdateService", "Clearing cached release data");
|
||||
changelogAdapter.releases = [];
|
||||
root.releases = [];
|
||||
changelogDataFileView.writeAdapter();
|
||||
}
|
||||
// Changelog fetching functions (removed cache - only fetch on version change via fetchUpgradeLog)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user