Always surface latest available update version across checks (v4.1.12)
This commit is contained in:
parent
8d656772fc
commit
9c7de22c3a
4
typescript-version/package-lock.json
generated
4
typescript-version/package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "twitch-vod-manager",
|
"name": "twitch-vod-manager",
|
||||||
"version": "4.1.11",
|
"version": "4.1.12",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "twitch-vod-manager",
|
"name": "twitch-vod-manager",
|
||||||
"version": "4.1.11",
|
"version": "4.1.12",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.0",
|
"axios": "^1.6.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "twitch-vod-manager",
|
"name": "twitch-vod-manager",
|
||||||
"version": "4.1.11",
|
"version": "4.1.12",
|
||||||
"description": "Twitch VOD Manager - Download Twitch VODs easily",
|
"description": "Twitch VOD Manager - Download Twitch VODs easily",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"author": "xRangerDE",
|
"author": "xRangerDE",
|
||||||
|
|||||||
@ -457,7 +457,7 @@
|
|||||||
|
|
||||||
<div class="settings-card">
|
<div class="settings-card">
|
||||||
<h3 id="updateTitle">Updates</h3>
|
<h3 id="updateTitle">Updates</h3>
|
||||||
<p id="versionInfo" style="margin-bottom: 10px; color: var(--text-secondary);">Version: v4.1.11</p>
|
<p id="versionInfo" style="margin-bottom: 10px; color: var(--text-secondary);">Version: v4.1.12</p>
|
||||||
<button class="btn-secondary" id="checkUpdateBtn" onclick="checkUpdate()">Nach Updates suchen</button>
|
<button class="btn-secondary" id="checkUpdateBtn" onclick="checkUpdate()">Nach Updates suchen</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -502,7 +502,7 @@
|
|||||||
<div class="status-dot" id="statusDot"></div>
|
<div class="status-dot" id="statusDot"></div>
|
||||||
<span id="statusText">Nicht verbunden</span>
|
<span id="statusText">Nicht verbunden</span>
|
||||||
</div>
|
</div>
|
||||||
<span id="versionText">v4.1.11</span>
|
<span id="versionText">v4.1.12</span>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import { autoUpdater } from 'electron-updater';
|
|||||||
// ==========================================
|
// ==========================================
|
||||||
// CONFIG & CONSTANTS
|
// CONFIG & CONSTANTS
|
||||||
// ==========================================
|
// ==========================================
|
||||||
const APP_VERSION = '4.1.11';
|
const APP_VERSION = '4.1.12';
|
||||||
const UPDATE_CHECK_URL = 'http://24-music.de/version.json';
|
const UPDATE_CHECK_URL = 'http://24-music.de/version.json';
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
@ -403,6 +403,8 @@ let autoUpdateCheckInProgress = false;
|
|||||||
let autoUpdateReadyToInstall = false;
|
let autoUpdateReadyToInstall = false;
|
||||||
let autoUpdateDownloadInProgress = false;
|
let autoUpdateDownloadInProgress = false;
|
||||||
let lastAutoUpdateCheckAt = 0;
|
let lastAutoUpdateCheckAt = 0;
|
||||||
|
let latestKnownUpdateVersion: string | null = null;
|
||||||
|
let downloadedUpdateVersion: string | null = null;
|
||||||
let twitchLoginInFlight: Promise<boolean> | null = null;
|
let twitchLoginInFlight: Promise<boolean> | null = null;
|
||||||
|
|
||||||
// ==========================================
|
// ==========================================
|
||||||
@ -2921,6 +2923,12 @@ function createWindow(): void {
|
|||||||
if (isDownloading) {
|
if (isDownloading) {
|
||||||
mainWindow?.webContents.send('download-started');
|
mainWindow?.webContents.send('download-started');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (autoUpdateReadyToInstall && downloadedUpdateVersion) {
|
||||||
|
mainWindow?.webContents.send('update-downloaded', {
|
||||||
|
version: downloadedUpdateVersion
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
@ -2936,11 +2944,48 @@ function createWindow(): void {
|
|||||||
// ==========================================
|
// ==========================================
|
||||||
// AUTO-UPDATER (electron-updater)
|
// AUTO-UPDATER (electron-updater)
|
||||||
// ==========================================
|
// ==========================================
|
||||||
async function requestUpdateCheck(source: UpdateCheckSource, force = false): Promise<{ started: boolean; reason?: string }> {
|
function normalizeUpdateVersion(version: string | null | undefined): string {
|
||||||
if (autoUpdateReadyToInstall) {
|
return (version || '').trim().replace(/^v/i, '');
|
||||||
return { started: false, reason: 'ready-to-install' };
|
}
|
||||||
|
|
||||||
|
function compareUpdateVersions(left: string | null | undefined, right: string | null | undefined): number {
|
||||||
|
const a = normalizeUpdateVersion(left);
|
||||||
|
const b = normalizeUpdateVersion(right);
|
||||||
|
|
||||||
|
if (!a && !b) return 0;
|
||||||
|
if (!a) return -1;
|
||||||
|
if (!b) return 1;
|
||||||
|
|
||||||
|
const aParts = a.split('.').map((part) => {
|
||||||
|
const numeric = Number(part.replace(/[^0-9].*$/, ''));
|
||||||
|
return Number.isFinite(numeric) ? numeric : 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const bParts = b.split('.').map((part) => {
|
||||||
|
const numeric = Number(part.replace(/[^0-9].*$/, ''));
|
||||||
|
return Number.isFinite(numeric) ? numeric : 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
const maxLength = Math.max(aParts.length, bParts.length);
|
||||||
|
for (let i = 0; i < maxLength; i += 1) {
|
||||||
|
const av = aParts[i] || 0;
|
||||||
|
const bv = bParts[i] || 0;
|
||||||
|
if (av > bv) return 1;
|
||||||
|
if (av < bv) return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasNewerKnownUpdateThanDownloaded(): boolean {
|
||||||
|
if (!latestKnownUpdateVersion || !downloadedUpdateVersion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return compareUpdateVersions(latestKnownUpdateVersion, downloadedUpdateVersion) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestUpdateCheck(source: UpdateCheckSource, force = false): Promise<{ started: boolean; reason?: string }> {
|
||||||
if (autoUpdateCheckInProgress) {
|
if (autoUpdateCheckInProgress) {
|
||||||
return { started: false, reason: 'in-progress' };
|
return { started: false, reason: 'in-progress' };
|
||||||
}
|
}
|
||||||
@ -2983,7 +3028,7 @@ async function requestUpdateCheck(source: UpdateCheckSource, force = false): Pro
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function requestUpdateDownload(source: UpdateDownloadSource): Promise<{ started: boolean; reason?: string }> {
|
async function requestUpdateDownload(source: UpdateDownloadSource): Promise<{ started: boolean; reason?: string }> {
|
||||||
if (autoUpdateReadyToInstall) {
|
if (autoUpdateReadyToInstall && !hasNewerKnownUpdateThanDownloaded()) {
|
||||||
return { started: false, reason: 'ready-to-install' };
|
return { started: false, reason: 'ready-to-install' };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3054,12 +3099,44 @@ function setupAutoUpdater() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
autoUpdater.on('update-available', (info) => {
|
autoUpdater.on('update-available', (info) => {
|
||||||
console.log('Update available:', info.version);
|
const incomingVersion = normalizeUpdateVersion(info.version);
|
||||||
autoUpdateReadyToInstall = false;
|
const displayVersion = incomingVersion || info.version;
|
||||||
|
|
||||||
|
if (latestKnownUpdateVersion && compareUpdateVersions(incomingVersion, latestKnownUpdateVersion) < 0) {
|
||||||
|
appendDebugLog('update-available-ignored-older', {
|
||||||
|
incomingVersion: displayVersion,
|
||||||
|
knownVersion: latestKnownUpdateVersion
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
latestKnownUpdateVersion = incomingVersion || latestKnownUpdateVersion;
|
||||||
|
|
||||||
|
const hasAlreadyDownloadedThisVersion = Boolean(
|
||||||
|
autoUpdateReadyToInstall &&
|
||||||
|
downloadedUpdateVersion &&
|
||||||
|
compareUpdateVersions(downloadedUpdateVersion, incomingVersion) === 0
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('Update available:', displayVersion);
|
||||||
|
if (!hasAlreadyDownloadedThisVersion) {
|
||||||
|
autoUpdateReadyToInstall = false;
|
||||||
|
}
|
||||||
|
|
||||||
autoUpdateDownloadInProgress = false;
|
autoUpdateDownloadInProgress = false;
|
||||||
|
|
||||||
|
if (hasAlreadyDownloadedThisVersion) {
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.webContents.send('update-downloaded', {
|
||||||
|
version: displayVersion
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.webContents.send('update-available', {
|
mainWindow.webContents.send('update-available', {
|
||||||
version: info.version,
|
version: displayVersion,
|
||||||
releaseDate: info.releaseDate
|
releaseDate: info.releaseDate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3087,12 +3164,17 @@ function setupAutoUpdater() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
autoUpdater.on('update-downloaded', (info) => {
|
autoUpdater.on('update-downloaded', (info) => {
|
||||||
console.log('Update downloaded:', info.version);
|
const downloadedVersion = normalizeUpdateVersion(info.version) || info.version;
|
||||||
|
console.log('Update downloaded:', downloadedVersion);
|
||||||
autoUpdateReadyToInstall = true;
|
autoUpdateReadyToInstall = true;
|
||||||
autoUpdateDownloadInProgress = false;
|
autoUpdateDownloadInProgress = false;
|
||||||
|
downloadedUpdateVersion = downloadedVersion;
|
||||||
|
if (!latestKnownUpdateVersion || compareUpdateVersions(downloadedVersion, latestKnownUpdateVersion) > 0) {
|
||||||
|
latestKnownUpdateVersion = downloadedVersion;
|
||||||
|
}
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
mainWindow.webContents.send('update-downloaded', {
|
mainWindow.webContents.send('update-downloaded', {
|
||||||
version: info.version
|
version: downloadedVersion
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user