From c18987e3b425533ddd65ee9cd3191bf18353ca8c Mon Sep 17 00:00:00 2001 From: Lhcfl Date: Sat, 18 May 2024 21:09:11 +0800 Subject: [PATCH] feat: fold poll --- .../client/src/components/MkNotificationFolded.vue | 6 ++++++ packages/client/src/scripts/fold.ts | 8 +++++++- packages/client/src/types/notification.ts | 12 +++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/client/src/components/MkNotificationFolded.vue b/packages/client/src/components/MkNotificationFolded.vue index a6678c9f71..0c6dd60163 100644 --- a/packages/client/src/components/MkNotificationFolded.vue +++ b/packages/client/src/components/MkNotificationFolded.vue @@ -12,6 +12,10 @@ v-if="notification.type === 'renote'" :class="icon('ph-rocket-launch', false)" > + 0) { res = i18n.t("_notification.andCountUsers", { diff --git a/packages/client/src/scripts/fold.ts b/packages/client/src/scripts/fold.ts index f693b7526b..fe98ecb50f 100644 --- a/packages/client/src/scripts/fold.ts +++ b/packages/client/src/scripts/fold.ts @@ -68,6 +68,8 @@ export function foldNotifications(ns: entities.Notification[]) { return `renote-${n.note.renote.id}`; case "reaction": return `reaction-${n.reaction}-of-${n.note.id}`; + case "pollVote": + return `pollVote-${n.note.id}`; default: { return `${n.id}`; } @@ -78,7 +80,11 @@ export function foldNotifications(ns: entities.Notification[]) { function check( ns: entities.Notification[], ): ns is FoldableNotification[] { - return represent.type === "renote" || represent.type === "reaction"; + return ( + represent.type === "renote" || + represent.type === "reaction" || + represent.type === "pollVote" + ); } if (!check(ns)) { return represent; diff --git a/packages/client/src/types/notification.ts b/packages/client/src/types/notification.ts index 0b7090ae6b..8501c4c625 100644 --- a/packages/client/src/types/notification.ts +++ b/packages/client/src/types/notification.ts @@ -2,7 +2,8 @@ import type { entities } from "firefish-js"; export type FoldableNotification = | entities.RenoteNotification - | entities.ReactionNotification; + | entities.ReactionNotification + | entities.PollVoteNotification; interface Fold { id: string; @@ -21,11 +22,16 @@ export type ReactionNotificationFolded = Fold & { reaction: string; }; +export type PollVotedNotificationFolded = Fold; + export type GetNotificationFoldedType = T["type"] extends "renote" ? RenoteNotificationFolded - : ReactionNotificationFolded; + : T["type"] extends "reaction" + ? ReactionNotificationFolded + : PollVotedNotificationFolded; export type NotificationFolded = | RenoteNotificationFolded - | ReactionNotificationFolded; + | ReactionNotificationFolded + | PollVotedNotificationFolded;