improve whats new dialog

This commit is contained in:
pa
2026-03-22 23:46:52 +09:00
parent deb27c3fa6
commit e08de71e96
7 changed files with 225 additions and 207 deletions
+88 -43
View File
@@ -7,7 +7,7 @@ import { logWebRequest } from '../services/appConfig';
import { branches } from '../shared/constants';
import {
getWhatsNewRelease,
getWhatsNewReleaseKey
normalizeReleaseVersion
} from '../shared/constants/whatsNewReleases';
import { changeLogRemoveLinks } from '../shared/utils';
@@ -15,6 +15,12 @@ import configRepository from '../services/config';
import * as workerTimers from 'worker-timers';
const emptyWhatsNewDialog = () => ({
visible: false,
titleKey: '',
items: []
});
export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
const { t } = useI18n();
@@ -40,12 +46,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
buildName: '',
changeLog: ''
});
const whatsNewDialog = ref({
visible: false,
version: '',
releaseKey: '',
items: []
});
const whatsNewDialog = ref(emptyWhatsNewDialog());
const pendingVRCXUpdate = ref(false);
const pendingVRCXInstall = ref('');
const updateInProgress = ref(false);
@@ -82,10 +83,25 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
await initBranch();
await loadVrcxId();
if (await compareAppVersion()) {
await showWhatsNewDialog();
let checkedForUpdatesDuringAnnouncement = false;
if (await shouldAnnounceCurrentVersion()) {
const shown = await showWhatsNewDialog();
if (shown) {
await markCurrentVersionAsSeen();
} else if (isRecognizedStableReleaseVersion()) {
const result = await showChangeLogDialog({ prefetch: true });
checkedForUpdatesDuringAnnouncement = result.checkedForUpdates;
if (result.shown) {
await markCurrentVersionAsSeen();
}
}
} else {
await syncCurrentVersionState();
}
if (autoUpdateVRCX.value !== 'Off') {
if (
autoUpdateVRCX.value !== 'Off' &&
!checkedForUpdatesDuringAnnouncement
) {
await checkForVRCXUpdate();
}
}
@@ -130,51 +146,58 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
await configRepository.setString('VRCX_branch', branch.value);
}
async function compareAppVersion() {
async function hasVersionChanged() {
const lastVersion = await configRepository.getString(
'VRCX_lastVRCXVersion',
''
);
if (lastVersion !== currentVersion.value) {
await configRepository.setString(
'VRCX_lastVRCXVersion',
currentVersion.value
);
return branch.value === 'Stable' && lastVersion;
return lastVersion !== currentVersion.value;
}
async function markCurrentVersionAsSeen() {
await configRepository.setString(
'VRCX_lastVRCXVersion',
currentVersion.value
);
}
async function syncCurrentVersionState() {
if (await hasVersionChanged()) {
await markCurrentVersionAsSeen();
return true;
}
return false;
}
/**
* @returns {string}
*/
function getCurrentWhatsNewReleaseKey() {
return getWhatsNewReleaseKey(currentVersion.value);
async function shouldAnnounceCurrentVersion() {
if (branch.value !== 'Stable' || !isRecognizedStableReleaseVersion()) {
return false;
}
const lastVersion = await configRepository.getString(
'VRCX_lastVRCXVersion',
''
);
return Boolean(lastVersion) && lastVersion !== currentVersion.value;
}
function isRecognizedStableReleaseVersion() {
return Boolean(normalizeReleaseVersion(currentVersion.value));
}
/**
* @returns {Promise<boolean>}
*/
async function showWhatsNewDialog() {
const releaseKey = getCurrentWhatsNewReleaseKey();
const release = getWhatsNewRelease(releaseKey);
const release = getWhatsNewRelease(currentVersion.value);
if (!release) {
whatsNewDialog.value = {
visible: false,
version: '',
releaseKey: '',
items: []
};
whatsNewDialog.value = emptyWhatsNewDialog();
return false;
}
const displayVersion = currentVersion.value.replace(/^VRCX\s+/, '');
whatsNewDialog.value = {
visible: true,
version: release.releaseLabel || displayVersion,
releaseKey,
titleKey: release.titleKey,
items: release.items.map((item) => ({ ...item }))
};
@@ -242,9 +265,8 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
currentVersion.value === 'VRCX Nightly Build' ||
currentVersion.value === 'VRCX Build'
) {
changeLogDialog.value.changeLog = '-';
// ignore custom builds
return;
return false;
}
if (branch.value === 'Beta') {
// move Beta users to stable
@@ -269,7 +291,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
json = JSON.parse(response.data);
} catch (error) {
console.error('Failed to check for VRCX update', error);
return;
return false;
} finally {
checkingForVRCXUpdate.value = false;
}
@@ -279,7 +301,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
message: `${response.status} ${response.data}`
})
);
return;
return false;
}
pendingVRCXUpdate.value = false;
logWebRequest('[EXTERNAL GET]', url, `(${response.status})`, json);
@@ -290,7 +312,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
setLatestAppVersion(releaseName);
VRCXUpdateDialog.value.updatePendingIsLatest = false;
if (autoUpdateVRCX.value === 'Off') {
return;
return true;
}
if (releaseName === pendingVRCXInstall.value) {
// update already downloaded
@@ -300,7 +322,7 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
json.assets
);
if (!downloadUrl) {
return;
return true;
}
pendingVRCXUpdate.value = true;
if (updateToastRelease.value !== releaseName) {
@@ -325,7 +347,9 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
);
}
}
return true;
}
return false;
}
async function showVRCXUpdateDialog() {
const D = VRCXUpdateDialog.value;
@@ -441,9 +465,31 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
break;
}
}
function showChangeLogDialog() {
async function showChangeLogDialog(options = {}) {
const { prefetch = false } = options;
if (prefetch) {
const loaded = await ensureChangeLogReady();
if (!loaded) {
return { shown: false, checkedForUpdates: true };
}
changeLogDialog.value.visible = true;
return { shown: true, checkedForUpdates: true };
}
changeLogDialog.value.visible = true;
checkForVRCXUpdate();
void ensureChangeLogReady();
return { shown: true, checkedForUpdates: true };
}
async function ensureChangeLogReady() {
if (
changeLogDialog.value.buildName &&
changeLogDialog.value.changeLog
) {
return true;
}
return checkForVRCXUpdate();
}
function restartVRCX(isUpgrade) {
if (!LINUX) {
@@ -486,7 +532,6 @@ export const useVRCXUpdaterStore = defineStore('VRCXUpdater', () => {
setAutoUpdateVRCX,
setBranch,
compareAppVersion,
showWhatsNewDialog,
closeWhatsNewDialog,
openChangeLogDialogOnly,