feat: Implement Electron window state persistence, update checking with splash screen and banner, and external link metadata fetching.
All checks were successful
Build and Release / build-and-release (push) Successful in 12m18s
All checks were successful
Build and Release / build-and-release (push) Successful in 12m18s
This commit is contained in:
@@ -346,6 +346,44 @@ app.whenReady().then(async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// Flatpak update check
|
||||
ipcMain.handle('check-flatpak-update', async () => {
|
||||
const isFlatpak = fs.existsSync('/.flatpak-info') || !!process.env.FLATPAK_ID;
|
||||
if (!isFlatpak) return { isFlatpak: false };
|
||||
|
||||
try {
|
||||
const yaml = await httpGet('https://gitea.moyettes.com/Moyettes/DiscordClone/releases/download/latest/latest-linux.yml');
|
||||
if (!yaml) return { isFlatpak: true, updateAvailable: false };
|
||||
|
||||
const versionMatch = yaml.match(/^version:\s*(.+)$/m);
|
||||
if (!versionMatch) return { isFlatpak: true, updateAvailable: false };
|
||||
|
||||
const latestVersion = versionMatch[1].trim();
|
||||
const currentVersion = app.getVersion();
|
||||
|
||||
// Semver comparison: determine if update exists and its severity
|
||||
const latest = latestVersion.split('.').map(Number);
|
||||
const current = currentVersion.split('.').map(Number);
|
||||
let updateAvailable = false;
|
||||
let updateType = 'patch'; // 'major', 'minor', or 'patch'
|
||||
for (let i = 0; i < Math.max(latest.length, current.length); i++) {
|
||||
const l = latest[i] || 0;
|
||||
const c = current[i] || 0;
|
||||
if (l > c) {
|
||||
updateAvailable = true;
|
||||
updateType = i === 0 ? 'major' : i === 1 ? 'minor' : 'patch';
|
||||
break;
|
||||
}
|
||||
if (l < c) break;
|
||||
}
|
||||
|
||||
return { isFlatpak: true, updateAvailable, updateType, latestVersion, currentVersion };
|
||||
} catch (err) {
|
||||
console.error('Flatpak update check error:', err.message);
|
||||
return { isFlatpak: true, updateAvailable: false };
|
||||
}
|
||||
});
|
||||
|
||||
ipcMain.handle('open-external', async (event, url) => {
|
||||
await shell.openExternal(url);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user