diff --git a/apps/app-frontend/src/App.vue b/apps/app-frontend/src/App.vue index b22ead562..5fd41453d 100644 --- a/apps/app-frontend/src/App.vue +++ b/apps/app-frontend/src/App.vue @@ -24,9 +24,20 @@ import SplashScreen from '@/components/ui/SplashScreen.vue' import ModrinthLoadingIndicator from '@/components/modrinth-loading-indicator' import { handleError, useNotifications } from '@/store/notifications.js' import { command_listener, offline_listener, warning_listener } from '@/helpers/events.js' -import { ArrowLeftFromLineIcon, ArrowRightFromLineIcon, ChatIcon, MaximizeIcon, MinimizeIcon } from '@/assets/icons' +import { + ArrowLeftFromLineIcon, + ArrowRightFromLineIcon, + ChatIcon, + MaximizeIcon, + MinimizeIcon, +} from '@/assets/icons' import { getOS, isDev, isOffline, showLauncherLogsFolder } from '@/helpers/utils.js' -import { mixpanel_init, mixpanel_is_loaded, mixpanel_opt_out_tracking, mixpanel_track } from '@/helpers/mixpanel.js' +import { + mixpanel_init, + mixpanel_is_loaded, + mixpanel_opt_out_tracking, + mixpanel_track, +} from '@/helpers/mixpanel.js' import { useDisableClicks } from '@/composables/click.js' import { openExternal } from '@/helpers/external.js' import { await_sync, check_safe_loading_bars_complete } from '@/helpers/state.js' @@ -67,6 +78,7 @@ const os = ref('') const instances = useInstances() const { instancesByPlayed } = storeToRefs(instances) +watch(() => instances) defineExpose({ initialize: async () => { @@ -78,9 +90,8 @@ defineExpose({ opt_out_analytics, collapsed_navigation, advanced_rendering, - fully_onboarded - } = - await get() + fully_onboarded, + } = await get() // video should play if the user is not on linux, and has not onboarded os.value = await getOS() // videoPlaying.value = !fully_onboarded && os.value !== 'Linux' @@ -98,7 +109,10 @@ defineExpose({ mixpanel_init('014c7d6a336d0efaefe3aca91063748d', { debug: dev, persistence: 'localStorage' }) if (opt_out_analytics) { - console.info('[AR • Hard Disable Patch] • OPT_OUT_ANALYTICS (DISABLED) status is ', opt_out_analytics) + console.info( + '[AR • Hard Disable Patch] • OPT_OUT_ANALYTICS (DISABLED) status is ', + opt_out_analytics, + ) mixpanel_opt_out_tracking() } mixpanel_track('Launched', { version, dev, fully_onboarded }) @@ -120,8 +134,8 @@ defineExpose({ notificationsWrapper.value.addNotification({ title: 'Warning', text: e.message, - type: 'warn' - }) + type: 'warn', + }), ) // if (showOnboarding.value) { @@ -132,7 +146,7 @@ defineExpose({ isLoading.value = false failureText.value = e os.value = await getOS() - } + }, }) const confirmClose = async () => { @@ -140,8 +154,8 @@ const confirmClose = async () => { 'An action is currently in progress. Are you sure you want to exit?', { title: 'AstralRinth', - type: 'warning' - } + type: 'warning', + }, ) return confirmed } @@ -156,7 +170,7 @@ const handleClose = async () => { // (Exception: if the user is changing config directory, which takes control of the state, and it's taking a significant amount of time for some reason) const isSafe = await Promise.race([ check_safe_loading_bars_complete(), - new Promise((r) => setTimeout(r, 2000)) + new Promise((r) => setTimeout(r, 2000)), ]) if (!isSafe) { const response = await confirmClose() @@ -203,7 +217,7 @@ command_listener(async (e) => { if (e.path.endsWith('.mrpack')) { await install_from_file(e.path).catch(handleError) mixpanel_track('InstanceCreate', { - source: 'CreationModalFileDrop' + source: 'CreationModalFileDrop', }) } } else { @@ -215,6 +229,19 @@ command_listener(async (e) => { const toggleSidebar = () => { sidebarOpen.value = !sidebarOpen.value } + +async function openInstance(instance) { + const instancePath = `/instance/${encodeURIComponent(instance.path)}/` + if (route.path.startsWith('/instance')) { + await router.replace({ path: `/library` }).then(() => { + setTimeout(() => { + router.replace({ path: instancePath }).catch(() => { }) + }, 128) + }) + } else { + router.push({ path: instancePath }) + } +}