mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-05 06:16:05 +02:00
refactor: app.js (#1291)
* refactor: frontend * Fix avatar gallery sort * Update .NET dependencies * Update npm dependencies electron v37.1.0 * bulkRefreshFriends * fix dark theme * Remove crowdin * Fix config.json dialog not updating * VRCX log file fixes & add Cef log * Remove SharedVariable, fix startup * Revert init theme change * Logging date not working? Fix WinformThemer designer error * Add Cef request hander, no more escaping main page * clean * fix * fix * clean * uh * Apply thememode at startup, fixes random user colours * Split database into files * Instance info remove empty lines * Open external VRC links with VRCX * Electron fixes * fix userdialog style * ohhhh * fix store * fix store * fix: load all group members after kicking a user * fix: world dialog favorite button style * fix: Clear VRCX Cache Timer input value * clean * Fix VR overlay * Fix VR overlay 2 * Fix Discord discord rich presence for RPC worlds * Clean up age verified user tags * Fix playerList being occupied after program reload * no `this` * Fix login stuck loading * writable: false * Hide dialogs on logout * add flush sync option * rm LOGIN event * rm LOGOUT event * remove duplicate event listeners * remove duplicate event listeners * clean * remove duplicate event listeners * clean * fix theme style * fix t * clearable * clean * fix ipcEvent * Small changes * Popcorn Palace support * Remove checkActiveFriends * Clean up * Fix dragEnterCef * Block API requests when not logged in * Clear state on login & logout * Fix worldDialog instances not updating * use <script setup> * Fix avatar change event, CheckGameRunning at startup * Fix image dragging * fix * Remove PWI * fix updateLoop * add webpack-dev-server to dev environment * rm unnecessary chunks * use <script setup> * webpack-dev-server changes * use <script setup> * use <script setup> * Fix UGC text size * Split login event * t * use <script setup> * fix * Update .gitignore and enable checkJs in jsconfig * fix i18n t * use <script setup> * use <script setup> * clean * global types * fix * use checkJs for debugging * Add watchState for login watchers * fix .vue template * type fixes * rm Vue.filter * Cef v138.0.170, VC++ 2022 * Settings fixes * Remove 'USER:CURRENT' * clean up 2FA callbacks * remove userApply * rm i18n import * notification handling to use notification store methods * refactor favorite handling to use favorite store methods and clean up event emissions * refactor moderation handling to use dedicated functions for player moderation events * refactor friend handling to use dedicated functions for friend events * Fix program startup, move lang init * Fix friend state * Fix status change error * Fix user notes diff * fix * rm group event * rm auth event * rm avatar event * clean * clean * getUser * getFriends * getFavoriteWorlds, getFavoriteAvatars * AvatarGalleryUpload btn style & package.json update * Fix friend requests * Apply user * Apply world * Fix note diff * Fix VR overlay * Fixes * Update build scripts * Apply avatar * Apply instance * Apply group * update hidden VRC+ badge * Fix sameInstance "private" * fix 502/504 API errors * fix 502/504 API errors * clean * Fix friend in same instance on orange showing twice in friends list * Add back in broken friend state repair methods * add types --------- Co-authored-by: Natsumi <cmcooper123@hotmail.com>
This commit is contained in:
@@ -0,0 +1,321 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, reactive } from 'vue';
|
||||
import * as workerTimers from 'worker-timers';
|
||||
import { $app } from '../../app';
|
||||
import { t } from '../../plugin';
|
||||
import configRepository from '../../service/config';
|
||||
import { useVrcxStore } from '../vrcx';
|
||||
import { useVRCXUpdaterStore } from '../vrcxUpdater';
|
||||
|
||||
export const useGeneralSettingsStore = defineStore('GeneralSettings', () => {
|
||||
const vrcxStore = useVrcxStore();
|
||||
const VRCXUpdaterStore = useVRCXUpdaterStore();
|
||||
const state = reactive({
|
||||
isStartAtWindowsStartup: false,
|
||||
isStartAsMinimizedState: false,
|
||||
isCloseToTray: false,
|
||||
disableGpuAcceleration: false,
|
||||
disableVrOverlayGpuAcceleration: false,
|
||||
localFavoriteFriendsGroups: [],
|
||||
udonExceptionLogging: false,
|
||||
logResourceLoad: false,
|
||||
logEmptyAvatars: false,
|
||||
autoStateChangeEnabled: false,
|
||||
autoStateChangeAloneStatus: 'join me',
|
||||
autoStateChangeCompanyStatus: 'busy',
|
||||
autoStateChangeInstanceTypes: [],
|
||||
autoStateChangeNoFriends: false,
|
||||
autoAcceptInviteRequests: 'Off'
|
||||
});
|
||||
|
||||
async function initGeneralSettings() {
|
||||
const [
|
||||
isStartAtWindowsStartup,
|
||||
isStartAsMinimizedState,
|
||||
isCloseToTray,
|
||||
isCloseToTrayConfigBool,
|
||||
disableGpuAccelerationStr,
|
||||
disableVrOverlayGpuAccelerationStr,
|
||||
localFavoriteFriendsGroupsStr,
|
||||
udonExceptionLogging,
|
||||
logResourceLoad,
|
||||
logEmptyAvatars,
|
||||
autoStateChangeEnabled,
|
||||
autoStateChangeAloneStatus,
|
||||
autoStateChangeCompanyStatus,
|
||||
autoStateChangeInstanceTypesStr,
|
||||
autoAcceptInviteRequests
|
||||
] = await Promise.all([
|
||||
configRepository.getBool('VRCX_StartAtWindowsStartup', false),
|
||||
VRCXStorage.Get('VRCX_StartAsMinimizedState'),
|
||||
VRCXStorage.Get('VRCX_CloseToTray'),
|
||||
configRepository.getBool('VRCX_CloseToTray'),
|
||||
VRCXStorage.Get('VRCX_DisableGpuAcceleration'),
|
||||
VRCXStorage.Get('VRCX_DisableVrOverlayGpuAcceleration'),
|
||||
configRepository.getString('VRCX_localFavoriteFriendsGroups', '[]'),
|
||||
configRepository.getBool('VRCX_udonExceptionLogging', false),
|
||||
configRepository.getBool('VRCX_logResourceLoad', false),
|
||||
configRepository.getBool('VRCX_logEmptyAvatars', false),
|
||||
configRepository.getBool('VRCX_autoStateChangeEnabled', false),
|
||||
configRepository.getString(
|
||||
'VRCX_autoStateChangeAloneStatus',
|
||||
'join me'
|
||||
),
|
||||
configRepository.getString(
|
||||
'VRCX_autoStateChangeCompanyStatus',
|
||||
'busy'
|
||||
),
|
||||
configRepository.getString(
|
||||
'VRCX_autoStateChangeInstanceTypes',
|
||||
'[]'
|
||||
),
|
||||
configRepository.getString('VRCX_autoAcceptInviteRequests', 'Off')
|
||||
]);
|
||||
|
||||
state.isStartAtWindowsStartup = isStartAtWindowsStartup;
|
||||
state.isStartAsMinimizedState = isStartAsMinimizedState === 'true';
|
||||
|
||||
if (isCloseToTrayConfigBool) {
|
||||
state.isCloseToTray = isCloseToTrayConfigBool;
|
||||
|
||||
await VRCXStorage.Set(
|
||||
'VRCX_CloseToTray',
|
||||
state.isCloseToTray.toString()
|
||||
);
|
||||
await configRepository.remove('VRCX_CloseToTray');
|
||||
} else {
|
||||
state.isCloseToTray = isCloseToTray === 'true';
|
||||
}
|
||||
|
||||
state.disableGpuAcceleration = disableGpuAccelerationStr === 'true';
|
||||
state.disableVrOverlayGpuAcceleration =
|
||||
disableVrOverlayGpuAccelerationStr === 'true';
|
||||
state.localFavoriteFriendsGroups = JSON.parse(
|
||||
localFavoriteFriendsGroupsStr
|
||||
);
|
||||
state.udonExceptionLogging = udonExceptionLogging;
|
||||
state.logResourceLoad = logResourceLoad;
|
||||
state.logEmptyAvatars = logEmptyAvatars;
|
||||
state.autoStateChangeEnabled = autoStateChangeEnabled;
|
||||
state.autoStateChangeAloneStatus = autoStateChangeAloneStatus;
|
||||
state.autoStateChangeCompanyStatus = autoStateChangeCompanyStatus;
|
||||
state.autoStateChangeInstanceTypes = JSON.parse(
|
||||
autoStateChangeInstanceTypesStr
|
||||
);
|
||||
state.autoAcceptInviteRequests = autoAcceptInviteRequests;
|
||||
}
|
||||
|
||||
initGeneralSettings();
|
||||
|
||||
const isStartAtWindowsStartup = computed(
|
||||
() => state.isStartAtWindowsStartup
|
||||
);
|
||||
const isStartAsMinimizedState = computed(
|
||||
() => state.isStartAsMinimizedState
|
||||
);
|
||||
const disableGpuAcceleration = computed(() => state.disableGpuAcceleration);
|
||||
const isCloseToTray = computed(() => state.isCloseToTray);
|
||||
const disableVrOverlayGpuAcceleration = computed(
|
||||
() => state.disableVrOverlayGpuAcceleration
|
||||
);
|
||||
const localFavoriteFriendsGroups = computed(
|
||||
() => state.localFavoriteFriendsGroups
|
||||
);
|
||||
const udonExceptionLogging = computed(() => state.udonExceptionLogging);
|
||||
const logResourceLoad = computed(() => state.logResourceLoad);
|
||||
const logEmptyAvatars = computed(() => state.logEmptyAvatars);
|
||||
const autoStateChangeEnabled = computed(() => state.autoStateChangeEnabled);
|
||||
const autoStateChangeAloneStatus = computed(
|
||||
() => state.autoStateChangeAloneStatus
|
||||
);
|
||||
const autoStateChangeCompanyStatus = computed(
|
||||
() => state.autoStateChangeCompanyStatus
|
||||
);
|
||||
const autoStateChangeInstanceTypes = computed(
|
||||
() => state.autoStateChangeInstanceTypes
|
||||
);
|
||||
const autoStateChangeNoFriends = computed(
|
||||
() => state.autoStateChangeNoFriends
|
||||
);
|
||||
const autoAcceptInviteRequests = computed(
|
||||
() => state.autoAcceptInviteRequests
|
||||
);
|
||||
|
||||
function setIsStartAtWindowsStartup() {
|
||||
state.isStartAtWindowsStartup = !state.isStartAtWindowsStartup;
|
||||
configRepository.setBool(
|
||||
'VRCX_StartAtWindowsStartup',
|
||||
state.isStartAtWindowsStartup
|
||||
);
|
||||
AppApi.SetStartup(state.isStartAtWindowsStartup);
|
||||
}
|
||||
function setIsStartAsMinimizedState() {
|
||||
state.isStartAsMinimizedState = !state.isStartAsMinimizedState;
|
||||
VRCXStorage.Set(
|
||||
'VRCX_StartAsMinimizedState',
|
||||
state.isStartAsMinimizedState.toString()
|
||||
);
|
||||
}
|
||||
function setIsCloseToTray() {
|
||||
state.isCloseToTray = !state.isCloseToTray;
|
||||
VRCXStorage.Set('VRCX_CloseToTray', state.isCloseToTray.toString());
|
||||
}
|
||||
function setDisableGpuAcceleration() {
|
||||
state.disableGpuAcceleration = !state.disableGpuAcceleration;
|
||||
VRCXStorage.Set(
|
||||
'VRCX_DisableGpuAcceleration',
|
||||
state.disableGpuAcceleration.toString()
|
||||
);
|
||||
}
|
||||
function setDisableVrOverlayGpuAcceleration() {
|
||||
state.disableVrOverlayGpuAcceleration =
|
||||
!state.disableVrOverlayGpuAcceleration;
|
||||
VRCXStorage.Set(
|
||||
'VRCX_DisableVrOverlayGpuAcceleration',
|
||||
state.disableVrOverlayGpuAcceleration.toString()
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {string[]} value
|
||||
*/
|
||||
function setLocalFavoriteFriendsGroups(value) {
|
||||
state.localFavoriteFriendsGroups = value;
|
||||
configRepository.setString(
|
||||
'VRCX_localFavoriteFriendsGroups',
|
||||
JSON.stringify(value)
|
||||
);
|
||||
}
|
||||
function setUdonExceptionLogging() {
|
||||
state.udonExceptionLogging = !state.udonExceptionLogging;
|
||||
configRepository.setBool(
|
||||
'VRCX_udonExceptionLogging',
|
||||
state.udonExceptionLogging
|
||||
);
|
||||
}
|
||||
function setLogResourceLoad() {
|
||||
state.logResourceLoad = !state.logResourceLoad;
|
||||
configRepository.setBool('VRCX_logResourceLoad', state.logResourceLoad);
|
||||
}
|
||||
function setLogEmptyAvatars() {
|
||||
state.logEmptyAvatars = !state.logEmptyAvatars;
|
||||
configRepository.setBool('VRCX_logEmptyAvatars', state.logEmptyAvatars);
|
||||
}
|
||||
function setAutoStateChangeEnabled() {
|
||||
state.autoStateChangeEnabled = !state.autoStateChangeEnabled;
|
||||
configRepository.setBool(
|
||||
'VRCX_autoStateChangeEnabled',
|
||||
state.autoStateChangeEnabled
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
function setAutoStateChangeAloneStatus(value) {
|
||||
state.autoStateChangeAloneStatus = value;
|
||||
configRepository.setString(
|
||||
'VRCX_autoStateChangeAloneStatus',
|
||||
state.autoStateChangeAloneStatus
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
function setAutoStateChangeCompanyStatus(value) {
|
||||
state.autoStateChangeCompanyStatus = value;
|
||||
configRepository.setString(
|
||||
'VRCX_autoStateChangeCompanyStatus',
|
||||
state.autoStateChangeCompanyStatus
|
||||
);
|
||||
}
|
||||
function setAutoStateChangeInstanceTypes(value) {
|
||||
state.autoStateChangeInstanceTypes = value;
|
||||
configRepository.setString(
|
||||
'VRCX_autoStateChangeInstanceTypes',
|
||||
JSON.stringify(state.autoStateChangeInstanceTypes)
|
||||
);
|
||||
}
|
||||
function setAutoStateChangeNoFriends() {
|
||||
state.autoStateChangeNoFriends = !state.autoStateChangeNoFriends;
|
||||
configRepository.setBool(
|
||||
'VRCX_autoStateChangeNoFriends',
|
||||
state.autoStateChangeNoFriends
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param {string} value
|
||||
*/
|
||||
function setAutoAcceptInviteRequests(value) {
|
||||
state.autoAcceptInviteRequests = value;
|
||||
configRepository.setString(
|
||||
'VRCX_autoAcceptInviteRequests',
|
||||
state.autoAcceptInviteRequests
|
||||
);
|
||||
}
|
||||
|
||||
function promptProxySettings() {
|
||||
$app.$prompt(
|
||||
t('prompt.proxy_settings.description'),
|
||||
t('prompt.proxy_settings.header'),
|
||||
{
|
||||
distinguishCancelAndClose: true,
|
||||
confirmButtonText: t('prompt.proxy_settings.restart'),
|
||||
cancelButtonText: t('prompt.proxy_settings.close'),
|
||||
inputValue: vrcxStore.proxyServer,
|
||||
inputPlaceholder: t('prompt.proxy_settings.placeholder'),
|
||||
callback: async (action, instance) => {
|
||||
vrcxStore.proxyServer = instance.inputValue;
|
||||
await VRCXStorage.Set(
|
||||
'VRCX_ProxyServer',
|
||||
vrcxStore.proxyServer
|
||||
);
|
||||
await VRCXStorage.Flush();
|
||||
await new Promise((resolve) => {
|
||||
workerTimers.setTimeout(resolve, 100);
|
||||
});
|
||||
if (action === 'confirm') {
|
||||
const { restartVRCX } = VRCXUpdaterStore;
|
||||
const isUpgrade = false;
|
||||
restartVRCX(isUpgrade);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
|
||||
isStartAtWindowsStartup,
|
||||
isStartAsMinimizedState,
|
||||
isCloseToTray,
|
||||
disableGpuAcceleration,
|
||||
disableVrOverlayGpuAcceleration,
|
||||
localFavoriteFriendsGroups,
|
||||
udonExceptionLogging,
|
||||
logResourceLoad,
|
||||
logEmptyAvatars,
|
||||
autoStateChangeEnabled,
|
||||
autoStateChangeAloneStatus,
|
||||
autoStateChangeCompanyStatus,
|
||||
autoStateChangeInstanceTypes,
|
||||
autoStateChangeNoFriends,
|
||||
autoAcceptInviteRequests,
|
||||
|
||||
setIsStartAtWindowsStartup,
|
||||
setIsStartAsMinimizedState,
|
||||
setIsCloseToTray,
|
||||
setDisableGpuAcceleration,
|
||||
setDisableVrOverlayGpuAcceleration,
|
||||
setLocalFavoriteFriendsGroups,
|
||||
setUdonExceptionLogging,
|
||||
setLogResourceLoad,
|
||||
setLogEmptyAvatars,
|
||||
setAutoStateChangeEnabled,
|
||||
setAutoStateChangeAloneStatus,
|
||||
setAutoStateChangeCompanyStatus,
|
||||
setAutoStateChangeInstanceTypes,
|
||||
setAutoStateChangeNoFriends,
|
||||
setAutoAcceptInviteRequests,
|
||||
promptProxySettings
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user