diff --git a/src/service/database/tableAlter.js b/src/service/database/tableAlter.js index eeca84ab..24cc95d8 100644 --- a/src/service/database/tableAlter.js +++ b/src/service/database/tableAlter.js @@ -65,14 +65,22 @@ const tableAlter = { }, async updateTableForAvatarHistory() { + var tables = []; await sqliteService.execute((dbRow) => { - const columnExists = dbRow.some((row) => row.name === 'time'); - if (!columnExists) { - sqliteService.executeNonQuery( - `ALTER TABLE ${dbVars.userPrefix}_avatar_history ADD time INTEGER DEFAULT 0` + tables.push(dbRow[0]); + }, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_avatar_history'`); + for (var tableName of tables) { + try { + await sqliteService.executeNonQuery( + `ALTER TABLE ${tableName} ADD time INTEGER DEFAULT 0` ); + } catch (e) { + e = e.toString(); + if (e.indexOf('duplicate column name') === -1) { + console.error(e); + } } - }, `PRAGMA table_info(${dbVars.userPrefix}_avatar_history);`); + } } }; diff --git a/src/stores/auth.js b/src/stores/auth.js index f4484d3e..7fc7b8fe 100644 --- a/src/stores/auth.js +++ b/src/stores/auth.js @@ -17,12 +17,14 @@ import { useNotificationStore } from './notification'; import { useAdvancedSettingsStore } from './settings/advanced'; import { useUpdateLoopStore } from './updateLoop'; import { useUserStore } from './user'; +import { useVrcxStore } from './vrcx'; export const useAuthStore = defineStore('Auth', () => { const advancedSettingsStore = useAdvancedSettingsStore(); const notificationStore = useNotificationStore(); const userStore = useUserStore(); const updateLoopStore = useUpdateLoopStore(); + const vrcxStore = useVrcxStore(); const { t } = useI18n(); const state = reactive({ @@ -138,6 +140,13 @@ export const useAuthStore = defineStore('Auth', () => { } }); + const attemptingAutoLogin = computed({ + get: () => state.attemptingAutoLogin, + set: (value) => { + state.attemptingAutoLogin = value; + } + }); + watch( [() => watchState.isLoggedIn, () => userStore.currentUser], ([isLoggedIn, currentUser]) => { @@ -859,6 +868,7 @@ export const useAuthStore = defineStore('Auth', () => { await database.initUserTables(userStore.currentUser.id); watchState.isLoggedIn = true; AppApi.CheckGameRunning(); // restore state from hot-reload + vrcxStore.updateDatabaseVersion(); } return { @@ -869,6 +879,7 @@ export const useAuthStore = defineStore('Auth', () => { twoFactorAuthDialogVisible, cachedConfig, enableCustomEndpoint, + attemptingAutoLogin, clearCookiesTryLogin, resendEmail2fa, diff --git a/src/stores/vrcx.js b/src/stores/vrcx.js index 57887498..5f36aaa6 100644 --- a/src/stores/vrcx.js +++ b/src/stores/vrcx.js @@ -95,7 +95,6 @@ export const useVrcxStore = defineStore('Vrcx', () => { 'VRCX_databaseVersion', 0 ); - updateDatabaseVersion(); state.clearVRCXCacheFrequency = await configRepository.getInt( 'VRCX_clearVRCXCacheFrequency', @@ -233,6 +232,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { } async function updateDatabaseVersion() { + // requires dbVars.userPrefix to be already set const databaseVersion = 12; let msgBox; if (state.databaseVersion < databaseVersion) { @@ -768,6 +768,7 @@ export const useVrcxStore = defineStore('Vrcx', () => { processScreenshot, ipcEvent, dragEnterCef, - backupVrcRegistry + backupVrcRegistry, + updateDatabaseVersion }; });