Skip to content

Commit fdd56ae

Browse files
committed
feat(web): implement notification filtering
1 parent fc9bd8f commit fdd56ae

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

web/components/Notifications/List.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
getNotifications,
44
NOTIFICATION_FRAGMENT,
55
} from "./graphql/notification.query";
6-
import type { NotificationType } from "~/composables/gql/graphql";
6+
import type { Importance, NotificationType } from "~/composables/gql/graphql";
77
import { useFragment } from "~/composables/gql/fragment-masking";
88
import { useQuery } from "@vue/apollo-composable";
99
import { vInfiniteScroll } from "@vueuse/components";
@@ -15,19 +15,22 @@ const props = withDefaults(
1515
defineProps<{
1616
type: NotificationType;
1717
pageSize?: number;
18+
importance?: Importance;
1819
}>(),
1920
{
2021
pageSize: 15,
22+
importance: undefined,
2123
}
2224
);
2325
24-
const { result, error, fetchMore } = useQuery(getNotifications, {
26+
const { result, error, fetchMore } = useQuery(getNotifications, () => ({
2527
filter: {
2628
offset: 0,
2729
limit: props.pageSize,
2830
type: props.type,
31+
importance: props.importance,
2932
},
30-
});
33+
}));
3134
3235
watch(error, (newVal) => {
3336
console.log("[getNotifications] error:", newVal);
@@ -52,6 +55,7 @@ async function onLoadMore() {
5255
offset: notifications.value.length,
5356
limit: props.pageSize,
5457
type: props.type,
58+
importance: props.importance,
5559
},
5660
},
5761
});

web/components/Notifications/Sidebar.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import {
99
} from "@/components/shadcn/sheet";
1010
1111
import { archiveAllNotifications } from "./graphql/notification.query";
12+
import type { Importance} from "~/composables/gql/graphql";
1213
import { NotificationType } from "~/composables/gql/graphql";
1314
import { useMutation } from "@vue/apollo-composable";
1415
1516
const { mutate: archiveAll, loading: loadingArchiveAll } = useMutation(
1617
archiveAllNotifications
1718
);
1819
const { teleportTarget, determineTeleportTarget } = useTeleport();
20+
const importance = ref<Importance | undefined>(undefined);
1921
</script>
2022

2123
<template>
@@ -57,7 +59,9 @@ const { teleportTarget, determineTeleportTarget } = useTeleport();
5759
Archive All
5860
</Button>
5961

60-
<Select>
62+
<Select
63+
@update:model-value="(val) => {importance = val as Importance}"
64+
>
6165
<SelectTrigger class="bg-secondary border-0 h-auto">
6266
<SelectValue
6367
class="text-muted-foreground"
@@ -67,20 +71,26 @@ const { teleportTarget, determineTeleportTarget } = useTeleport();
6771
<SelectContent :to="teleportTarget">
6872
<SelectGroup>
6973
<SelectLabel>Notification Types</SelectLabel>
70-
<SelectItem value="alert">Alert</SelectItem>
71-
<SelectItem value="info">Info</SelectItem>
72-
<SelectItem value="warning">Warning</SelectItem>
74+
<SelectItem :value="Importance.Alert">Alert</SelectItem>
75+
<SelectItem :value="Importance.Info">Info</SelectItem>
76+
<SelectItem :value="Importance.Warning">Warning</SelectItem>
7377
</SelectGroup>
7478
</SelectContent>
7579
</Select>
7680
</div>
7781

7882
<TabsContent value="unread" class="flex-1 min-h-0 mt-3">
79-
<NotificationsList :type="NotificationType.Unread" />
83+
<NotificationsList
84+
:importance="importance"
85+
:type="NotificationType.Unread"
86+
/>
8087
</TabsContent>
8188

8289
<TabsContent value="archived" class="flex-1 min-h-0 mt-3">
83-
<NotificationsList :type="NotificationType.Archive" />
90+
<NotificationsList
91+
:importance="importance"
92+
:type="NotificationType.Archive"
93+
/>
8494
</TabsContent>
8595
</Tabs>
8696
</div>

web/composables/gql/graphql.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable */
1+
22
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
33
export type Maybe<T> = T | null;
44
export type InputMaybe<T> = Maybe<T>;
@@ -821,6 +821,7 @@ export type Node = {
821821
export type Notification = Node & {
822822
__typename?: 'Notification';
823823
description: Scalars['String']['output'];
824+
formattedTimestamp?: Maybe<Scalars['String']['output']>;
824825
id: Scalars['ID']['output'];
825826
importance: Importance;
826827
link?: Maybe<Scalars['String']['output']>;

0 commit comments

Comments
 (0)