From a6c5093cf561f4e54b4f5ebf7b019c04fccd9de1 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Mon, 2 Dec 2024 12:33:53 +0100 Subject: [PATCH] feat: :sparkles: Refactor notifications --- app.vue | 32 ++--- components/composer/composer.vue | 112 +++++++--------- components/headers/greeting.vue | 25 ---- components/modals-old/composable.ts | 25 ---- components/modals-old/confirmation.vue | 124 ------------------ components/modals-old/service.ts | 52 -------- components/modals-old/types.ts | 11 -- components/notifications/follow-request.vue | 87 ++++++++++++ components/notifications/notification.vue | 43 ++++-- components/sidebars/sidebar.vue | 2 +- .../social-elements/notifications/notif.vue | 116 ---------------- components/timelines/timeline.vue | 37 ++++-- 12 files changed, 213 insertions(+), 453 deletions(-) delete mode 100644 components/headers/greeting.vue delete mode 100644 components/modals-old/composable.ts delete mode 100644 components/modals-old/confirmation.vue delete mode 100644 components/modals-old/service.ts delete mode 100644 components/modals-old/types.ts create mode 100644 components/notifications/follow-request.vue delete mode 100644 components/social-elements/notifications/notif.vue diff --git a/app.vue b/app.vue index 9d82bd8..c4fbfec 100644 --- a/app.vue +++ b/app.vue @@ -1,19 +1,21 @@ \ No newline at end of file diff --git a/components/modals-old/composable.ts b/components/modals-old/composable.ts deleted file mode 100644 index d5682fe..0000000 --- a/components/modals-old/composable.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { - confirmModalService, - confirmModalWithInputService, -} from "./service.ts"; -import type { ConfirmModalOptions, ConfirmModalResult } from "./types.ts"; - -export function useConfirmModal() { - const confirm = ( - options: ConfirmModalOptions, - ): Promise => { - return confirmModalService.confirm(options); - }; - - const confirmWithInput = ( - options: ConfirmModalOptions, - placeholder?: string, - ): Promise => { - return confirmModalWithInputService.confirm(options, placeholder); - }; - - return { - confirm, - confirmWithInput, - }; -} diff --git a/components/modals-old/confirmation.vue b/components/modals-old/confirmation.vue deleted file mode 100644 index c3a6db5..0000000 --- a/components/modals-old/confirmation.vue +++ /dev/null @@ -1,124 +0,0 @@ - - - \ No newline at end of file diff --git a/components/modals-old/service.ts b/components/modals-old/service.ts deleted file mode 100644 index 06025f7..0000000 --- a/components/modals-old/service.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ref } from "vue"; -import type { ConfirmModalOptions, ConfirmModalResult } from "./types.ts"; - -class ConfirmModalService { - private modalRef = ref<{ - open: (options: ConfirmModalOptions) => Promise; - } | null>(null); - - register(modal: { - open: (options: ConfirmModalOptions) => Promise; - }) { - this.modalRef.value = modal; - } - - confirm(options: ConfirmModalOptions): Promise { - if (!this.modalRef.value) { - throw new Error("Confirmation modal not initialized"); - } - return this.modalRef.value.open(options); - } -} - -class ConfirmModalWithInputService { - private modalRef = ref<{ - open: ( - options: ConfirmModalOptions, - placeholder?: string, - ) => Promise; - } | null>(null); - - register(modal: { - open: ( - options: ConfirmModalOptions, - placeholder?: string, - ) => Promise; - }) { - this.modalRef.value = modal; - } - - confirm( - options: ConfirmModalOptions, - placeholder?: string, - ): Promise { - if (!this.modalRef.value) { - throw new Error("Confirmation modal not initialized"); - } - return this.modalRef.value.open(options, placeholder); - } -} - -export const confirmModalService = new ConfirmModalService(); -export const confirmModalWithInputService = new ConfirmModalWithInputService(); diff --git a/components/modals-old/types.ts b/components/modals-old/types.ts deleted file mode 100644 index 34f40e6..0000000 --- a/components/modals-old/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface ConfirmModalOptions { - title?: string; - message: string; - confirmText?: string; - cancelText?: string; -} - -export interface ConfirmModalResult { - confirmed: boolean; - value?: string; -} diff --git a/components/notifications/follow-request.vue b/components/notifications/follow-request.vue new file mode 100644 index 0000000..f18c1cf --- /dev/null +++ b/components/notifications/follow-request.vue @@ -0,0 +1,87 @@ + + + \ No newline at end of file diff --git a/components/notifications/notification.vue b/components/notifications/notification.vue index f6fc49d..9159440 100644 --- a/components/notifications/notification.vue +++ b/components/notifications/notification.vue @@ -1,32 +1,45 @@ \ No newline at end of file + diff --git a/components/sidebars/sidebar.vue b/components/sidebars/sidebar.vue index a8d21ee..e2a0905 100644 --- a/components/sidebars/sidebar.vue +++ b/components/sidebars/sidebar.vue @@ -275,7 +275,7 @@ const instance = useInstance(); - +