From 5818873d4030ead462c5e9fc8ca37e16432e8b62 Mon Sep 17 00:00:00 2001 From: Creeperkatze Date: Tue, 30 Jun 2026 18:32:00 +0200 Subject: [PATCH 1/2] Fix update pill sizing --- .../src/components/ui/AppActionBar.vue | 36 +++---------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/apps/app-frontend/src/components/ui/AppActionBar.vue b/apps/app-frontend/src/components/ui/AppActionBar.vue index 143bc8d50b..240ff81e04 100644 --- a/apps/app-frontend/src/components/ui/AppActionBar.vue +++ b/apps/app-frontend/src/components/ui/AppActionBar.vue @@ -18,14 +18,11 @@ - +
@@ -141,7 +120,6 @@ import { DownloadIcon, DropdownIcon, OnlineIndicatorIcon, - RefreshCwIcon, StarIcon, StopCircleIcon, TerminalSquareIcon, @@ -158,9 +136,10 @@ import { } from '@modrinth/ui' import { convertFileSrc } from '@tauri-apps/api/core' import { Dropdown } from 'floating-vue' -import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue' +import { computed, onBeforeUnmount, onMounted, ref } from 'vue' import { useRouter } from 'vue-router' +import AppUpdateButton from '@/components/ui/app-update-button/index.vue' import { useInstallJobNotifications } from '@/composables/browse/install-job-notifications' import { trackEvent } from '@/helpers/analytics' import { loading_listener, process_listener } from '@/helpers/events' @@ -169,11 +148,6 @@ import { get_all as getRunningProcesses, kill as killProcess } from '@/helpers/p import type { LoadingBar } from '@/helpers/state' import { progress_bars_list } from '@/helpers/state' import type { GameInstance } from '@/helpers/types' -import { - appUpdateState, - downloadAvailableAppUpdate, - installAvailableAppUpdate, -} from '@/providers/app-update' const { handleError } = injectNotificationManager() const popupNotificationManager = injectPopupNotificationManager() @@ -238,84 +212,7 @@ const messages = defineMessages({ id: 'app.action-bar.view-active-downloads', defaultMessage: 'View active downloads', }, - update: { - id: 'app.action-bar.update', - defaultMessage: 'Update', - }, - downloadingUpdate: { - id: 'app.action-bar.downloading-update', - defaultMessage: 'Downloading update', - }, - reloadToUpdate: { - id: 'app.action-bar.reload-to-update', - defaultMessage: 'Reload to update', - }, -}) - -const { - downloading, - downloadPercent, - downloadProgress, - finishedDownloading, - isVisible: isUpdateVisible, - metered, - restarting, -} = appUpdateState - -const isUpdateDownloading = computed( - () => - downloading.value || - (downloadProgress.value > 0 && downloadProgress.value < 1 && !finishedDownloading.value), -) -const showUpdatePill = computed( - () => isUpdateVisible.value && (finishedDownloading.value || metered.value), -) -const animateReadyPill = ref(false) -const updateLabel = computed(() => { - if (isUpdateDownloading.value) { - return formatMessage(messages.downloadingUpdate) - } - - if (finishedDownloading.value) { - return formatMessage(messages.reloadToUpdate) - } - - return formatMessage(messages.update) }) -let readyPillAnimationFrame: number | null = null -watch([showUpdatePill, finishedDownloading], async ([show, ready], [wasShown, wasReady]) => { - if (readyPillAnimationFrame !== null) { - cancelAnimationFrame(readyPillAnimationFrame) - readyPillAnimationFrame = null - } - - if (!show || !ready) { - animateReadyPill.value = false - return - } - - if (wasShown && wasReady) { - return - } - - animateReadyPill.value = false - await nextTick() - readyPillAnimationFrame = requestAnimationFrame(() => { - animateReadyPill.value = true - readyPillAnimationFrame = null - }) -}) -async function handleUpdateClick() { - if (isUpdateDownloading.value) { - return - } - - if (finishedDownloading.value) { - await installAvailableAppUpdate() - } else { - await downloadAvailableAppUpdate() - } -} const currentProcesses = ref([]) const selectedProcess = ref() @@ -605,8 +502,5 @@ onBeforeUnmount(() => { unlistenProcess() unlistenLoading() installJobNotifications.dispose() - if (readyPillAnimationFrame !== null) { - cancelAnimationFrame(readyPillAnimationFrame) - } }) diff --git a/apps/app-frontend/src/components/ui/app-update-button/index.vue b/apps/app-frontend/src/components/ui/app-update-button/index.vue new file mode 100644 index 0000000000..6abf2532db --- /dev/null +++ b/apps/app-frontend/src/components/ui/app-update-button/index.vue @@ -0,0 +1,124 @@ + + +