From 3c8452f038ed706b10bbb60603575b52b9911fcd Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 9 Jun 2025 13:56:45 +1000 Subject: [PATCH 1/6] fix: missing CheckIcon import in LanguageSelector --- components/LanguageSelector.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/LanguageSelector.vue b/components/LanguageSelector.vue index 523b8e48..9d8c759a 100644 --- a/components/LanguageSelector.vue +++ b/components/LanguageSelector.vue @@ -107,7 +107,7 @@ import { ListboxOptions, } from "@headlessui/vue"; import { ChevronUpDownIcon } from "@heroicons/vue/16/solid"; -import { ArrowTopRightOnSquareIcon } from "@heroicons/vue/24/outline"; +import { ArrowTopRightOnSquareIcon, CheckIcon } from "@heroicons/vue/24/outline"; import type { Locale } from "vue-i18n"; const { locales, locale: currLocale, setLocale } = useI18n(); From 400e5222f4e6d8ed1e767b6e56aa6bc8a2c93140 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 9 Jun 2025 14:37:25 +1000 Subject: [PATCH 2/6] fix: #114 and error handling --- error.vue | 7 +++++- plugins/error-handler.ts | 4 ++-- server/internal/objects/transactional.ts | 2 +- server/internal/tasks/index.ts | 11 ++++++++-- server/plugins/redirect.ts | 27 ------------------------ 5 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 server/plugins/redirect.ts diff --git a/error.vue b/error.vue index 3e2e31ab..94c0cf19 100644 --- a/error.vue +++ b/error.vue @@ -21,13 +21,18 @@ async function signIn() { redirect: `/auth/signin?redirect=${encodeURIComponent(route.fullPath)}`, }); } +switch (statusCode) { + case 401: + case 403: + await signIn(); +} useHead({ title: t("errors.pageTitle", [statusCode ?? message]), }); if (import.meta.client) { - console.log(props.error); + console.warn(props.error); } diff --git a/plugins/error-handler.ts b/plugins/error-handler.ts index 53657f25..4337928e 100644 --- a/plugins/error-handler.ts +++ b/plugins/error-handler.ts @@ -1,5 +1,5 @@ export default defineNuxtPlugin((nuxtApp) => { - nuxtApp.vueApp.config.errorHandler = (error, instance, info) => { + nuxtApp.hook("vue:error", (error, instance, info) => { console.error(error, instance, info); - }; + }); }); diff --git a/server/internal/objects/transactional.ts b/server/internal/objects/transactional.ts index dc9134fe..3e89d7d0 100644 --- a/server/internal/objects/transactional.ts +++ b/server/internal/objects/transactional.ts @@ -39,7 +39,7 @@ export class ObjectTransactionalHandler { if (!transaction) return; let progress = 0; - const increment = (1 / transaction.size) * 100; + const increment = (100 / transaction.size); for (const [id, data] of transaction) { if (typeof data === "string") { diff --git a/server/internal/tasks/index.ts b/server/internal/tasks/index.ts index e5838c77..83a34469 100644 --- a/server/internal/tasks/index.ts +++ b/server/internal/tasks/index.ts @@ -374,8 +374,15 @@ export function wrapTaskContext( ): TaskRunContext { return { progress(progress) { - const scalar = 100 / (options.max - options.min); - const adjustedProgress = progress * scalar + options.min; + if (progress > 100 || progress < 0) { + console.warn("[wrapTaskContext] progress must be between 0 and 100"); + } + + // I was too tired to figure this out + // https://stackoverflow.com/a/929107 + const oldRange = 100; + const newRange = options.max - options.min; + const adjustedProgress = (progress * newRange) / oldRange + options.min; return context.progress(adjustedProgress); }, log(message) { diff --git a/server/plugins/redirect.ts b/server/plugins/redirect.ts deleted file mode 100644 index 8218a0cb..00000000 --- a/server/plugins/redirect.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { H3Error } from "h3"; -import sessionHandler from "../internal/session"; - -export default defineNitroPlugin((nitro) => { - nitro.hooks.hook("error", async (error, { event }) => { - if (!event) return; - - // Don't handle for API routes - if (event.path.startsWith("/api")) return; - if (event.path.startsWith("/auth")) return; - - // Make sure it's a web error - if (!(error instanceof H3Error)) return; - - switch (error.statusCode) { - case 401: - case 403: { - const user = await sessionHandler.getSession(event); - if (user) break; - return sendRedirect( - event, - `/auth/signin?redirect=${encodeURIComponent(event.path)}`, - ); - } - } - }); -}); From 72b3d6fbb6a160bd23e461a1d67b15a75363a645 Mon Sep 17 00:00:00 2001 From: DecDuck Date: Mon, 9 Jun 2025 15:38:41 +1000 Subject: [PATCH 3/6] fix: #97 --- pages/account/notifications.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/account/notifications.vue b/pages/account/notifications.vue index 7f691064..2a60d6d4 100644 --- a/pages/account/notifications.vue +++ b/pages/account/notifications.vue @@ -9,7 +9,7 @@