Merge branch 'fold-poll' into 'develop'

feat: fold poll notifications

Co-authored-by: Lhcfl <Lhcfl@outlook.com>

See merge request firefish/firefish!10869
This commit is contained in:
naskya 2024-05-18 21:31:21 +00:00
commit 3661c4da74
3 changed files with 22 additions and 4 deletions

View file

@ -12,6 +12,10 @@
v-if="notification.type === 'renote'"
:class="icon('ph-rocket-launch', false)"
></i>
<i
v-if="notification.type === 'pollVote'"
:class="icon('ph-microphone-stage', false)"
></i>
<XReactionIcon
v-else-if="
showEmojiReactions && notification.type === 'reaction'
@ -142,6 +146,8 @@ function getText() {
case "reaction":
res = i18n.ts._notification.reacted;
break;
case "pollVote":
res = i18n.ts._notification.voted;
}
if (userleft.value > 0) {
res = i18n.t("_notification.andCountUsers", {

View file

@ -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;

View file

@ -2,7 +2,8 @@ import type { entities } from "firefish-js";
export type FoldableNotification =
| entities.RenoteNotification
| entities.ReactionNotification;
| entities.ReactionNotification
| entities.PollVoteNotification;
interface Fold<T extends FoldableNotification> {
id: string;
@ -21,11 +22,16 @@ export type ReactionNotificationFolded = Fold<entities.ReactionNotification> & {
reaction: string;
};
export type PollVotedNotificationFolded = Fold<entities.PollVoteNotification>;
export type GetNotificationFoldedType<T extends FoldableNotification> =
T["type"] extends "renote"
? RenoteNotificationFolded
: ReactionNotificationFolded;
: T["type"] extends "reaction"
? ReactionNotificationFolded
: PollVotedNotificationFolded;
export type NotificationFolded =
| RenoteNotificationFolded
| ReactionNotificationFolded;
| ReactionNotificationFolded
| PollVotedNotificationFolded;