feat: fold poll
This commit is contained in:
parent
29023d7240
commit
c18987e3b4
3 changed files with 22 additions and 4 deletions
|
@ -12,6 +12,10 @@
|
||||||
v-if="notification.type === 'renote'"
|
v-if="notification.type === 'renote'"
|
||||||
:class="icon('ph-rocket-launch', false)"
|
:class="icon('ph-rocket-launch', false)"
|
||||||
></i>
|
></i>
|
||||||
|
<i
|
||||||
|
v-if="notification.type === 'pollVote'"
|
||||||
|
:class="icon('ph-microphone-stage', false)"
|
||||||
|
></i>
|
||||||
<XReactionIcon
|
<XReactionIcon
|
||||||
v-else-if="
|
v-else-if="
|
||||||
showEmojiReactions && notification.type === 'reaction'
|
showEmojiReactions && notification.type === 'reaction'
|
||||||
|
@ -141,6 +145,8 @@ function getText() {
|
||||||
case "reaction":
|
case "reaction":
|
||||||
res = i18n.ts._notification.reacted;
|
res = i18n.ts._notification.reacted;
|
||||||
break;
|
break;
|
||||||
|
case "pollVote":
|
||||||
|
res = i18n.ts._notification.voted;
|
||||||
}
|
}
|
||||||
if (userleft.value > 0) {
|
if (userleft.value > 0) {
|
||||||
res = i18n.t("_notification.andCountUsers", {
|
res = i18n.t("_notification.andCountUsers", {
|
||||||
|
|
|
@ -68,6 +68,8 @@ export function foldNotifications(ns: entities.Notification[]) {
|
||||||
return `renote-${n.note.renote.id}`;
|
return `renote-${n.note.renote.id}`;
|
||||||
case "reaction":
|
case "reaction":
|
||||||
return `reaction-${n.reaction}-of-${n.note.id}`;
|
return `reaction-${n.reaction}-of-${n.note.id}`;
|
||||||
|
case "pollVote":
|
||||||
|
return `pollVote-${n.note.id}`;
|
||||||
default: {
|
default: {
|
||||||
return `${n.id}`;
|
return `${n.id}`;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,11 @@ export function foldNotifications(ns: entities.Notification[]) {
|
||||||
function check(
|
function check(
|
||||||
ns: entities.Notification[],
|
ns: entities.Notification[],
|
||||||
): ns is FoldableNotification[] {
|
): ns is FoldableNotification[] {
|
||||||
return represent.type === "renote" || represent.type === "reaction";
|
return (
|
||||||
|
represent.type === "renote" ||
|
||||||
|
represent.type === "reaction" ||
|
||||||
|
represent.type === "pollVote"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (!check(ns)) {
|
if (!check(ns)) {
|
||||||
return represent;
|
return represent;
|
||||||
|
|
|
@ -2,7 +2,8 @@ import type { entities } from "firefish-js";
|
||||||
|
|
||||||
export type FoldableNotification =
|
export type FoldableNotification =
|
||||||
| entities.RenoteNotification
|
| entities.RenoteNotification
|
||||||
| entities.ReactionNotification;
|
| entities.ReactionNotification
|
||||||
|
| entities.PollVoteNotification;
|
||||||
|
|
||||||
interface Fold<T extends FoldableNotification> {
|
interface Fold<T extends FoldableNotification> {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -21,11 +22,16 @@ export type ReactionNotificationFolded = Fold<entities.ReactionNotification> & {
|
||||||
reaction: string;
|
reaction: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type PollVotedNotificationFolded = Fold<entities.PollVoteNotification>;
|
||||||
|
|
||||||
export type GetNotificationFoldedType<T extends FoldableNotification> =
|
export type GetNotificationFoldedType<T extends FoldableNotification> =
|
||||||
T["type"] extends "renote"
|
T["type"] extends "renote"
|
||||||
? RenoteNotificationFolded
|
? RenoteNotificationFolded
|
||||||
: ReactionNotificationFolded;
|
: T["type"] extends "reaction"
|
||||||
|
? ReactionNotificationFolded
|
||||||
|
: PollVotedNotificationFolded;
|
||||||
|
|
||||||
export type NotificationFolded =
|
export type NotificationFolded =
|
||||||
| RenoteNotificationFolded
|
| RenoteNotificationFolded
|
||||||
| ReactionNotificationFolded;
|
| ReactionNotificationFolded
|
||||||
|
| PollVotedNotificationFolded;
|
||||||
|
|
Loading…
Reference in a new issue