mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-30 20:23:46 +02:00
auto-login when db upgraded
This commit is contained in:
@@ -22,6 +22,7 @@ import { useGeneralSettingsStore } from './settings/general';
|
|||||||
import { useModalStore } from './modal';
|
import { useModalStore } from './modal';
|
||||||
import { useUpdateLoopStore } from './updateLoop';
|
import { useUpdateLoopStore } from './updateLoop';
|
||||||
import { useUserStore } from './user';
|
import { useUserStore } from './user';
|
||||||
|
import { useVrcxStore } from './vrcx';
|
||||||
import { watchState } from '../services/watchState';
|
import { watchState } from '../services/watchState';
|
||||||
|
|
||||||
import configRepository from '../services/config';
|
import configRepository from '../services/config';
|
||||||
@@ -36,6 +37,7 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const updateLoopStore = useUpdateLoopStore();
|
const updateLoopStore = useUpdateLoopStore();
|
||||||
const modalStore = useModalStore();
|
const modalStore = useModalStore();
|
||||||
|
const vrcxStore = useVrcxStore();
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@@ -177,6 +179,13 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function autoLoginAfterMounted() {
|
async function autoLoginAfterMounted() {
|
||||||
|
const canAutoLogin = await vrcxStore.waitForDatabaseInit();
|
||||||
|
if (!canAutoLogin) {
|
||||||
|
console.warn(
|
||||||
|
'Skipping auto-login after mount because database initialization did not complete successfully.'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!advancedSettingsStore.enablePrimaryPassword &&
|
!advancedSettingsStore.enablePrimaryPassword &&
|
||||||
(await configRepository.getString('lastUserLoggedIn')) !== null
|
(await configRepository.getString('lastUserLoggedIn')) !== null
|
||||||
@@ -800,6 +809,13 @@ export const useAuthStore = defineStore('Auth', () => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function handleAutoLogin() {
|
async function handleAutoLogin() {
|
||||||
|
const canAutoLogin = await vrcxStore.waitForDatabaseInit();
|
||||||
|
if (!canAutoLogin) {
|
||||||
|
console.warn(
|
||||||
|
'Skipping auto-login because database initialization did not complete successfully.'
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await runHandleAutoLoginFlow();
|
await runHandleAutoLoginFlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
fromVersion: 0,
|
fromVersion: 0,
|
||||||
toVersion: 0
|
toVersion: 0
|
||||||
});
|
});
|
||||||
|
const databaseReadyForAutoLogin = ref(false);
|
||||||
|
let resolveDatabaseInit = () => {};
|
||||||
|
const databaseInitComplete = new Promise((resolve) => {
|
||||||
|
resolveDatabaseInit = resolve;
|
||||||
|
});
|
||||||
|
|
||||||
const currentlyDroppingFile = ref(null);
|
const currentlyDroppingFile = ref(null);
|
||||||
const isRegistryBackupDialogVisible = ref(false);
|
const isRegistryBackupDialogVisible = ref(false);
|
||||||
@@ -90,7 +95,9 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function init() {
|
async function init() {
|
||||||
|
try {
|
||||||
if (LINUX) {
|
if (LINUX) {
|
||||||
|
try {
|
||||||
window.electron.ipcRenderer.on('launch-command', (command) => {
|
window.electron.ipcRenderer.on('launch-command', (command) => {
|
||||||
if (command) {
|
if (command) {
|
||||||
eventLaunchCommand(command);
|
eventLaunchCommand(command);
|
||||||
@@ -117,13 +124,22 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
window.electron.onBrowserFocus(() => {
|
window.electron.onBrowserFocus(() => {
|
||||||
vrcStatusStore.onBrowserFocus();
|
vrcStatusStore.onBrowserFocus();
|
||||||
});
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
'Failed to register Linux IPC handlers:',
|
||||||
|
err
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state.databaseVersion = await configRepository.getInt(
|
state.databaseVersion = await configRepository.getInt(
|
||||||
'VRCX_databaseVersion',
|
'VRCX_databaseVersion',
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
updateDatabaseVersion();
|
const databaseUpgradeSucceeded = await updateDatabaseVersion();
|
||||||
|
if (!databaseUpgradeSucceeded) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clearVRCXCacheFrequency.value = await configRepository.getInt(
|
clearVRCXCacheFrequency.value = await configRepository.getInt(
|
||||||
'VRCX_clearVRCXCacheFrequency',
|
'VRCX_clearVRCXCacheFrequency',
|
||||||
@@ -140,8 +156,11 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
await VRCXStorage.Set('VRCX_DisableGpuAcceleration', 'false');
|
await VRCXStorage.Set('VRCX_DisableGpuAcceleration', 'false');
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(await VRCXStorage.Get('VRCX_DisableVrOverlayGpuAcceleration')) ===
|
(
|
||||||
''
|
await VRCXStorage.Get(
|
||||||
|
'VRCX_DisableVrOverlayGpuAcceleration'
|
||||||
|
)
|
||||||
|
) === ''
|
||||||
) {
|
) {
|
||||||
await VRCXStorage.Set(
|
await VRCXStorage.Set(
|
||||||
'VRCX_DisableVrOverlayGpuAcceleration',
|
'VRCX_DisableVrOverlayGpuAcceleration',
|
||||||
@@ -149,9 +168,18 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
proxyServer.value = await VRCXStorage.Get('VRCX_ProxyServer');
|
proxyServer.value = await VRCXStorage.Get('VRCX_ProxyServer');
|
||||||
state.locationX = parseInt(await VRCXStorage.Get('VRCX_LocationX'), 10);
|
state.locationX = parseInt(
|
||||||
state.locationY = parseInt(await VRCXStorage.Get('VRCX_LocationY'), 10);
|
await VRCXStorage.Get('VRCX_LocationX'),
|
||||||
state.sizeWidth = parseInt(await VRCXStorage.Get('VRCX_SizeWidth'), 10);
|
10
|
||||||
|
);
|
||||||
|
state.locationY = parseInt(
|
||||||
|
await VRCXStorage.Get('VRCX_LocationY'),
|
||||||
|
10
|
||||||
|
);
|
||||||
|
state.sizeWidth = parseInt(
|
||||||
|
await VRCXStorage.Get('VRCX_SizeWidth'),
|
||||||
|
10
|
||||||
|
);
|
||||||
state.sizeHeight = parseInt(
|
state.sizeHeight = parseInt(
|
||||||
await VRCXStorage.Get('VRCX_SizeHeight'),
|
await VRCXStorage.Get('VRCX_SizeHeight'),
|
||||||
10
|
10
|
||||||
@@ -177,6 +205,10 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
database.setSearchTableSize(searchLimit.value);
|
database.setSearchTableSize(searchLimit.value);
|
||||||
|
|
||||||
refreshCustomScript();
|
refreshCustomScript();
|
||||||
|
databaseReadyForAutoLogin.value = true;
|
||||||
|
} finally {
|
||||||
|
resolveDatabaseInit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resetSearchIndexOnLogin();
|
resetSearchIndexOnLogin();
|
||||||
@@ -228,8 +260,15 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
dismissible: false
|
dismissible: false
|
||||||
});
|
});
|
||||||
AppApi.ShowDevTools();
|
AppApi.ShowDevTools();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForDatabaseInit() {
|
||||||
|
await databaseInitComplete;
|
||||||
|
return databaseReadyForAutoLogin.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -820,6 +859,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
|
|
||||||
appStartAt,
|
appStartAt,
|
||||||
databaseUpgradeState,
|
databaseUpgradeState,
|
||||||
|
databaseReadyForAutoLogin,
|
||||||
proxyServer,
|
proxyServer,
|
||||||
setProxyServer,
|
setProxyServer,
|
||||||
setIpcEnabled,
|
setIpcEnabled,
|
||||||
@@ -842,6 +882,7 @@ export const useVrcxStore = defineStore('Vrcx', () => {
|
|||||||
ipcEvent,
|
ipcEvent,
|
||||||
dragEnterCef,
|
dragEnterCef,
|
||||||
backupVrcRegistry,
|
backupVrcRegistry,
|
||||||
updateDatabaseVersion
|
updateDatabaseVersion,
|
||||||
|
waitForDatabaseInit
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user