0.8.0 beta fixes (#2154)

* initial fixes

* 0.8.0 beta fixes

* run actions

* run fmt

* Fix windows build

* Add purge cache opt

* add must revalidate to project req

* lint + clippy

* fix processes, open folder

* Update migrator to use old launcher cache for perf

* fix empty dirs not moving

* fix lint + create natives dir if not exist

* fix large request batches

* finish

* Fix deep linking on mac

* fix comp err

* fix comp err (2)

---------

Signed-off-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Geometrically
2024-08-16 23:20:11 -07:00
committed by GitHub
parent 3a4843fb46
commit 910e219c0e
66 changed files with 1961 additions and 1896 deletions

View File

@@ -1,16 +1,8 @@
<script setup>
import { computed, ref, onMounted } from 'vue'
import { RouterView, RouterLink, useRouter, useRoute } from 'vue-router'
import {
HomeIcon,
SearchIcon,
LibraryIcon,
PlusIcon,
SettingsIcon,
FileIcon,
XIcon,
} from '@modrinth/assets'
import { Button, Notifications, Card } from '@modrinth/ui'
import { HomeIcon, SearchIcon, LibraryIcon, PlusIcon, SettingsIcon, XIcon } from '@modrinth/assets'
import { Button, Notifications } from '@modrinth/ui'
import { useLoading, useTheming } from '@/store/state'
import AccountsCard from '@/components/ui/AccountsCard.vue'
import InstanceCreationModal from '@/components/ui/InstanceCreationModal.vue'
@@ -22,10 +14,10 @@ import ErrorModal from '@/components/ui/ErrorModal.vue'
import ModrinthLoadingIndicator from '@/components/modrinth-loading-indicator'
import { handleError, useNotifications } from '@/store/notifications.js'
import { command_listener, warning_listener } from '@/helpers/events.js'
import { MinimizeIcon, MaximizeIcon, ChatIcon } from '@/assets/icons'
import { MinimizeIcon, MaximizeIcon } from '@/assets/icons'
import { type } from '@tauri-apps/api/os'
import { appWindow } from '@tauri-apps/api/window'
import { isDev, getOS, showLauncherLogsFolder } from '@/helpers/utils.js'
import { isDev, getOS } from '@/helpers/utils.js'
import {
mixpanel_track,
mixpanel_init,
@@ -37,17 +29,18 @@ import { getVersion } from '@tauri-apps/api/app'
import { window as TauriWindow } from '@tauri-apps/api'
import { TauriEvent } from '@tauri-apps/api/event'
import URLConfirmModal from '@/components/ui/URLConfirmModal.vue'
import OnboardingScreen from '@/components/ui/tutorial/OnboardingScreen.vue'
import { install_from_file } from './helpers/pack'
import { useError } from '@/store/error.js'
import ModInstallModal from '@/components/ui/install_flow/ModInstallModal.vue'
import IncompatibilityWarningModal from '@/components/ui/install_flow/IncompatibilityWarningModal.vue'
import InstallConfirmModal from '@/components/ui/install_flow/InstallConfirmModal.vue'
import { useInstall } from '@/store/install.js'
import { invoke } from '@tauri-apps/api/tauri'
import { get_opening_command, initialize_state } from '@/helpers/state'
const themeStore = useTheming()
const urlModal = ref(null)
const isLoading = ref(true)
const offline = ref(!navigator.onLine)
window.addEventListener('offline', () => {
@@ -60,67 +53,77 @@ window.addEventListener('online', () => {
const showOnboarding = ref(false)
const nativeDecorations = ref(false)
const onboardingVideo = ref()
const failureText = ref(null)
const os = ref('')
defineExpose({
initialize: async () => {
isLoading.value = false
const {
native_decorations,
theme,
telemetry,
collapsed_navigation,
advanced_rendering,
onboarded,
} = await get()
// video should play if the user is not on linux, and has not onboarded
os.value = await getOS()
const dev = await isDev()
const version = await getVersion()
showOnboarding.value = !onboarded
const stateInitialized = ref(false)
nativeDecorations.value = native_decorations
if (os.value !== 'MacOS') appWindow.setDecorations(native_decorations)
async function setupApp() {
stateInitialized.value = true
const {
native_decorations,
theme,
telemetry,
collapsed_navigation,
advanced_rendering,
onboarded,
default_page,
} = await get()
themeStore.setThemeState(theme)
themeStore.collapsedNavigation = collapsed_navigation
themeStore.advancedRendering = advanced_rendering
if (default_page && default_page !== 'Home') {
await router.push({ name: default_page })
}
mixpanel_init('014c7d6a336d0efaefe3aca91063748d', { debug: dev, persistence: 'localStorage' })
if (telemetry) {
mixpanel_opt_out_tracking()
}
mixpanel_track('Launched', { version, dev, onboarded })
os.value = await getOS()
const dev = await isDev()
const version = await getVersion()
showOnboarding.value = !onboarded
if (!dev) document.addEventListener('contextmenu', (event) => event.preventDefault())
nativeDecorations.value = native_decorations
if (os.value !== 'MacOS') await appWindow.setDecorations(native_decorations)
if ((await type()) === 'Darwin') {
document.getElementsByTagName('html')[0].classList.add('mac')
} else {
document.getElementsByTagName('html')[0].classList.add('windows')
}
themeStore.setThemeState(theme)
themeStore.collapsedNavigation = collapsed_navigation
themeStore.advancedRendering = advanced_rendering
await warning_listener((e) =>
notificationsWrapper.value.addNotification({
title: 'Warning',
text: e.message,
type: 'warn',
}),
)
mixpanel_init('014c7d6a336d0efaefe3aca91063748d', { debug: dev, persistence: 'localStorage' })
if (!telemetry) {
mixpanel_opt_out_tracking()
}
mixpanel_track('Launched', { version, dev, onboarded })
if (showOnboarding.value) {
onboardingVideo.value.play()
}
},
failure: async (e) => {
isLoading.value = false
failureText.value = e
os.value = await getOS()
},
})
if (!dev) document.addEventListener('contextmenu', (event) => event.preventDefault())
if ((await type()) === 'Darwin') {
document.getElementsByTagName('html')[0].classList.add('mac')
} else {
document.getElementsByTagName('html')[0].classList.add('windows')
}
await warning_listener((e) =>
notificationsWrapper.value.addNotification({
title: 'Warning',
text: e.message,
type: 'warn',
}),
)
get_opening_command().then(handleCommand)
}
const stateFailed = ref(false)
initialize_state()
.then(() => {
setupApp().catch((err) => {
stateFailed.value = true
console.error(err)
error.showError(err, false, 'state_init')
})
})
.catch((err) => {
stateFailed.value = true
console.error('Failed to initialize app', err)
error.showError(err, false, 'state_init')
})
const handleClose = async () => {
await TauriWindow.getCurrent().close()
@@ -140,6 +143,7 @@ const route = useRoute()
const isOnBrowse = computed(() => route.path.startsWith('/browse'))
const loading = useLoading()
loading.setEnabled(false)
const notifications = useNotifications()
const notificationsWrapper = ref()
@@ -153,6 +157,8 @@ const installConfirmModal = ref()
const incompatibilityWarningModal = ref()
onMounted(() => {
invoke('show_window')
notifications.setNotifs(notificationsWrapper.value)
error.setErrorModal(errorModal.value)
@@ -204,7 +210,10 @@ document.querySelector('body').addEventListener('auxclick', function (e) {
const accounts = ref(null)
command_listener(async (e) => {
command_listener(handleCommand)
async function handleCommand(e) {
if (!e) return
if (e.event === 'RunMRPack') {
// RunMRPack should directly install a local mrpack given a path
if (e.path.endsWith('.mrpack')) {
@@ -217,53 +226,12 @@ command_listener(async (e) => {
// Other commands are URL-based (deep linking)
urlModal.value.show(e)
}
})
}
</script>
<template>
<div v-if="failureText" class="failure dark-mode">
<div class="appbar-failure dark-mode">
<Button v-if="os != 'MacOS'" icon-only @click="TauriWindow.getCurrent().close()">
<XIcon />
</Button>
</div>
<div class="error-view dark-mode">
<Card class="error-text">
<div class="label">
<h3>
<span class="label__title size-card-header">Failed to initialize</span>
</h3>
</div>
<div class="error-div">
Modrinth App failed to load correctly. This may be because of a corrupted file, or because
the app is missing crucial files.
</div>
<div class="error-div">You may be able to fix it one of the following ways:</div>
<ul class="error-div">
<li>Ennsuring you are connected to the internet, then try restarting the app.</li>
<li>Redownloading the app.</li>
</ul>
<div class="error-div">
If it still does not work, you can seek support using the link below. You should provide
the following error, as well as any recent launcher logs in the folder below.
</div>
<div class="error-div">The following error was provided:</div>
<Card class="error-message">
{{ failureText.message }}
</Card>
<div class="button-row push-right">
<Button @click="showLauncherLogsFolder"><FileIcon />Open launcher logs</Button>
<a class="btn" href="https://support.modrinth.com"> <ChatIcon /> Get support </a>
</div>
</Card>
</div>
</div>
<SplashScreen v-else-if="isLoading" app-loading />
<OnboardingScreen v-else-if="showOnboarding" :finish="() => (showOnboarding = false)" />
<div v-else class="container">
<SplashScreen v-if="!stateFailed" ref="splashScreen" data-tauri-drag-region />
<div v-if="stateInitialized" class="container">
<div class="nav-container">
<div class="nav-section">
<suspense>
@@ -449,53 +417,6 @@ command_listener(async (e) => {
}
}
.failure {
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
background-color: var(--color-bg);
.appbar-failure {
display: flex; /* Change to flex to align items horizontally */
justify-content: flex-end; /* Align items to the right */
height: 3.25rem;
//no select
user-select: none;
-webkit-user-select: none;
}
.error-view {
display: flex; /* Change to flex to align items horizontally */
justify-content: center;
width: 100%;
background-color: var(--color-bg);
color: var(--color-base);
.card {
background-color: var(--color-raised-bg);
}
.error-text {
display: flex;
max-width: 60%;
gap: 0.25rem;
flex-direction: column;
.error-div {
// spaced out
margin: 0.5rem;
}
.error-message {
margin: 0.5rem;
background-color: var(--color-button-bg);
}
}
}
}
.nav-container {
display: flex;
flex-direction: column;
@@ -580,3 +501,33 @@ command_listener(async (e) => {
}
}
</style>
<style>
.mac {
.nav-container {
padding-top: calc(var(--gap-md) + 1.75rem);
}
.account-card,
.card-section {
top: calc(var(--gap-md) + 1.75rem);
}
}
.windows {
.fake-appbar {
height: 2.5rem !important;
}
.window-controls {
display: flex !important;
}
.info-card {
right: 8rem;
}
.profile-card {
right: 8rem;
}
}
</style>