Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: filter notifications by type (#2371)
Co-authored-by: Xabi <xabi.rn@gmail.com> Co-authored-by: userquin <userquin@gmail.com>
- Loading branch information
1 parent
e9c5de5
commit 907d999
Showing
10 changed files
with
171 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { mastodon } from 'masto' | ||
import { NOTIFICATION_FILTER_TYPES } from '~/constants' | ||
|
||
/** | ||
* Typeguard to check if an object is a valid notification filter | ||
* @param obj the object to be checked | ||
* @returns boolean and assigns type to object if true | ||
*/ | ||
export function isNotificationFilter(obj: unknown): obj is mastodon.v1.NotificationType { | ||
return !!obj && NOTIFICATION_FILTER_TYPES.includes(obj as unknown as mastodon.v1.NotificationType) | ||
} | ||
|
||
/** | ||
* Typeguard to check if an object is a valid notification | ||
* @param obj the object to be checked | ||
* @returns boolean and assigns type to object if true | ||
*/ | ||
export function isNotification(obj: unknown): obj is mastodon.v1.NotificationType { | ||
return !!obj && ['mention', ...NOTIFICATION_FILTER_TYPES].includes(obj as unknown as mastodon.v1.NotificationType) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script setup lang="ts"> | ||
import type { mastodon } from 'masto' | ||
const route = useRoute() | ||
const { t } = useI18n() | ||
const filter = $computed<mastodon.v1.NotificationType | undefined>(() => { | ||
if (!isHydrated.value) | ||
return undefined | ||
const rawFilter = route.params?.filter | ||
const actualFilter = Array.isArray(rawFilter) ? rawFilter[0] : rawFilter | ||
if (isNotification(actualFilter)) | ||
return actualFilter | ||
}) | ||
useHydratedHead({ | ||
title: () => `${t(`tab.notifications_${filter ?? 'all'}`)} | ${t('nav.notifications')}`, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<TimelineNotifications v-if="isHydrated" :filter="filter" /> | ||
</template> |
This file was deleted.
Oops, something went wrong.