2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2023-01-10 05:16:59 +00:00
|
|
|
<div ref="elRef" :class="$style.root">
|
|
|
|
<div v-once :class="$style.head">
|
2023-01-16 05:18:11 +00:00
|
|
|
<MkAvatar v-if="notification.type === 'pollEnded'" :class="$style.icon" :user="notification.note.user" link preview/>
|
2023-01-21 04:14:55 +00:00
|
|
|
<MkAvatar v-else-if="notification.type === 'achievementEarned'" :class="$style.icon" :user="$i" link preview/>
|
2023-01-16 05:18:11 +00:00
|
|
|
<MkAvatar v-else-if="notification.user" :class="$style.icon" :user="notification.user" link preview/>
|
2023-01-10 05:16:59 +00:00
|
|
|
<img v-else-if="notification.icon" :class="$style.icon" :src="notification.icon" alt=""/>
|
|
|
|
<div :class="[$style.subIcon, $style['t_' + notification.type]]">
|
2022-12-19 10:01:30 +00:00
|
|
|
<i v-if="notification.type === 'follow'" class="ti ti-plus"></i>
|
|
|
|
<i v-else-if="notification.type === 'receiveFollowRequest'" class="ti ti-clock"></i>
|
|
|
|
<i v-else-if="notification.type === 'followRequestAccepted'" class="ti ti-check"></i>
|
2022-12-24 05:45:27 +00:00
|
|
|
<i v-else-if="notification.type === 'groupInvited'" class="ti ti-certificate-2"></i>
|
2022-12-19 10:01:30 +00:00
|
|
|
<i v-else-if="notification.type === 'renote'" class="ti ti-repeat"></i>
|
|
|
|
<i v-else-if="notification.type === 'reply'" class="ti ti-arrow-back-up"></i>
|
|
|
|
<i v-else-if="notification.type === 'mention'" class="ti ti-at"></i>
|
|
|
|
<i v-else-if="notification.type === 'quote'" class="ti ti-quote"></i>
|
|
|
|
<i v-else-if="notification.type === 'pollEnded'" class="ti ti-chart-arrows"></i>
|
2023-01-24 05:10:26 +00:00
|
|
|
<i v-else-if="notification.type === 'achievementEarned'" class="ti ti-medal"></i>
|
2021-10-22 17:44:52 +00:00
|
|
|
<!-- notification.reaction が null になることはまずないが、ここでoptional chaining使うと一部ブラウザで刺さるので念の為 -->
|
2023-01-08 05:22:04 +00:00
|
|
|
<MkReactionIcon
|
2022-06-05 03:26:36 +00:00
|
|
|
v-else-if="notification.type === 'reaction'"
|
2021-11-19 10:36:12 +00:00
|
|
|
ref="reactionRef"
|
2021-11-07 18:38:48 +00:00
|
|
|
:reaction="notification.reaction ? notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : notification.reaction"
|
|
|
|
:custom-emojis="notification.note.emojis"
|
|
|
|
:no-style="true"
|
2023-01-10 05:16:59 +00:00
|
|
|
style="width: 100%; height: 100%;"
|
2021-11-07 18:38:48 +00:00
|
|
|
/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-10 05:16:59 +00:00
|
|
|
<div :class="$style.tail">
|
|
|
|
<header :class="$style.header">
|
2022-03-06 07:06:27 +00:00
|
|
|
<span v-if="notification.type === 'pollEnded'">{{ i18n.ts._notification.pollEnded }}</span>
|
2023-01-21 04:14:55 +00:00
|
|
|
<span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.user" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
|
2020-03-28 09:07:41 +00:00
|
|
|
<span v-else>{{ notification.header }}</span>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</header>
|
2023-01-10 05:16:59 +00:00
|
|
|
<div v-once :class="$style.content">
|
|
|
|
<MkA v-if="notification.type === 'reaction'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :author="notification.note.user"/>
|
2023-01-10 05:16:59 +00:00
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.type === 'renote'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
|
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" :author="notification.note.renote.user"/>
|
2023-01-10 05:16:59 +00:00
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :author="notification.note.user"/>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.type === 'mention'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :author="notification.note.user"/>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.type === 'quote'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :author="notification.note.user"/>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<MkA v-else-if="notification.type === 'pollEnded'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-13 05:29:01 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :author="notification.note.user"/>
|
2023-01-10 05:16:59 +00:00
|
|
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
2023-01-08 02:30:40 +00:00
|
|
|
</MkA>
|
2023-01-21 04:14:55 +00:00
|
|
|
<MkA v-else-if="notification.type === 'achievementEarned'" :class="$style.text" to="/my/achievements">
|
|
|
|
{{ i18n.ts._achievements._types['_' + notification.achievement].title }}
|
|
|
|
</MkA>
|
2023-01-10 05:16:59 +00:00
|
|
|
<span v-else-if="notification.type === 'follow'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.youGotNewFollower }}<div v-if="full"><MkFollowButton :user="notification.user" :full="true"/></div></span>
|
|
|
|
<span v-else-if="notification.type === 'followRequestAccepted'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.followRequestAccepted }}</span>
|
|
|
|
<span v-else-if="notification.type === 'receiveFollowRequest'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.receiveFollowRequest }}<div v-if="full && !followRequestDone"><button class="_textButton" @click="acceptFollowRequest()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectFollowRequest()">{{ i18n.ts.reject }}</button></div></span>
|
|
|
|
<span v-else-if="notification.type === 'groupInvited'" :class="$style.text" style="opacity: 0.6;">{{ i18n.ts.groupInvited }}: <b>{{ notification.invitation.group.name }}</b><div v-if="full && !groupInviteDone"><button class="_textButton" @click="acceptGroupInvitation()">{{ i18n.ts.accept }}</button> | <button class="_textButton" @click="rejectGroupInvitation()">{{ i18n.ts.reject }}</button></div></span>
|
|
|
|
<span v-else-if="notification.type === 'app'" :class="$style.text">
|
2023-01-08 02:30:40 +00:00
|
|
|
<Mfm :text="notification.body" :nowrap="!full"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-28 05:34:44 +00:00
|
|
|
<script lang="ts" setup>
|
2023-01-03 01:12:37 +00:00
|
|
|
import { ref, shallowRef, onMounted, onUnmounted, watch } from 'vue';
|
2021-11-12 12:29:59 +00:00
|
|
|
import * as misskey from 'misskey-js';
|
2023-01-08 05:22:04 +00:00
|
|
|
import MkReactionIcon from '@/components/MkReactionIcon.vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import MkFollowButton from '@/components/MkFollowButton.vue';
|
|
|
|
import XReactionTooltip from '@/components/MkReactionTooltip.vue';
|
2022-06-05 03:26:36 +00:00
|
|
|
import { getNoteSummary } from '@/scripts/get-note-summary';
|
2021-11-28 11:29:37 +00:00
|
|
|
import { notePage } from '@/filters/note';
|
2021-11-11 17:02:25 +00:00
|
|
|
import { userPage } from '@/filters/user';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import * as os from '@/os';
|
2021-12-29 13:13:09 +00:00
|
|
|
import { stream } from '@/stream';
|
2021-11-12 14:53:10 +00:00
|
|
|
import { useTooltip } from '@/scripts/use-tooltip';
|
2023-01-21 04:14:55 +00:00
|
|
|
import { $i } from '@/account';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2022-06-28 05:34:44 +00:00
|
|
|
const props = withDefaults(defineProps<{
|
|
|
|
notification: misskey.entities.Notification;
|
|
|
|
withTime?: boolean;
|
|
|
|
full?: boolean;
|
|
|
|
}>(), {
|
|
|
|
withTime: false,
|
|
|
|
full: false,
|
|
|
|
});
|
|
|
|
|
2023-01-03 01:12:37 +00:00
|
|
|
const elRef = shallowRef<HTMLElement>(null);
|
2022-06-28 05:34:44 +00:00
|
|
|
const reactionRef = ref(null);
|
|
|
|
|
|
|
|
let readObserver: IntersectionObserver | undefined;
|
|
|
|
let connection;
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (!props.notification.isRead) {
|
|
|
|
readObserver = new IntersectionObserver((entries, observer) => {
|
|
|
|
if (!entries.some(entry => entry.isIntersecting)) return;
|
|
|
|
stream.send('readNotification', {
|
|
|
|
id: props.notification.id,
|
|
|
|
});
|
|
|
|
observer.disconnect();
|
2022-06-25 18:12:58 +00:00
|
|
|
});
|
2020-05-26 05:34:49 +00:00
|
|
|
|
2022-06-28 05:34:44 +00:00
|
|
|
readObserver.observe(elRef.value);
|
|
|
|
|
|
|
|
connection = stream.useChannel('main');
|
|
|
|
connection.on('readAllNotifications', () => readObserver.disconnect());
|
|
|
|
|
|
|
|
watch(props.notification.isRead, () => {
|
|
|
|
readObserver.disconnect();
|
2021-11-12 14:53:10 +00:00
|
|
|
});
|
2022-06-28 05:34:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
if (readObserver) readObserver.disconnect();
|
|
|
|
if (connection) connection.dispose();
|
|
|
|
});
|
2021-11-07 18:38:48 +00:00
|
|
|
|
2022-06-28 05:34:44 +00:00
|
|
|
const followRequestDone = ref(false);
|
|
|
|
const groupInviteDone = ref(false);
|
|
|
|
|
|
|
|
const acceptFollowRequest = () => {
|
|
|
|
followRequestDone.value = true;
|
|
|
|
os.api('following/requests/accept', { userId: props.notification.user.id });
|
|
|
|
};
|
|
|
|
|
|
|
|
const rejectFollowRequest = () => {
|
|
|
|
followRequestDone.value = true;
|
|
|
|
os.api('following/requests/reject', { userId: props.notification.user.id });
|
|
|
|
};
|
|
|
|
|
|
|
|
const acceptGroupInvitation = () => {
|
|
|
|
groupInviteDone.value = true;
|
|
|
|
os.apiWithDialog('users/groups/invitations/accept', { invitationId: props.notification.invitation.id });
|
|
|
|
};
|
|
|
|
|
|
|
|
const rejectGroupInvitation = () => {
|
|
|
|
groupInviteDone.value = true;
|
|
|
|
os.api('users/groups/invitations/reject', { invitationId: props.notification.invitation.id });
|
|
|
|
};
|
|
|
|
|
|
|
|
useTooltip(reactionRef, (showing) => {
|
|
|
|
os.popup(XReactionTooltip, {
|
|
|
|
showing,
|
|
|
|
reaction: props.notification.reaction ? props.notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : props.notification.reaction,
|
|
|
|
emojis: props.notification.note.emojis,
|
|
|
|
targetElement: reactionRef.value.$el,
|
|
|
|
}, {}, 'closed');
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-10 05:16:59 +00:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-01-29 19:37:25 +00:00
|
|
|
position: relative;
|
|
|
|
box-sizing: border-box;
|
2020-02-18 22:00:44 +00:00
|
|
|
padding: 24px 32px;
|
2020-01-29 19:37:25 +00:00
|
|
|
font-size: 0.9em;
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
display: flex;
|
2020-10-17 11:12:00 +00:00
|
|
|
contain: content;
|
2023-01-10 05:16:59 +00:00
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-01-10 05:16:59 +00:00
|
|
|
.head {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
flex-shrink: 0;
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
margin-right: 8px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.icon {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2023-01-10 05:16:59 +00:00
|
|
|
.subIcon {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
bottom: -2px;
|
|
|
|
right: -2px;
|
|
|
|
width: 20px;
|
|
|
|
height: 20px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border-radius: 100%;
|
|
|
|
background: var(--panel);
|
|
|
|
box-shadow: 0 0 0 3px var(--panel);
|
|
|
|
font-size: 12px;
|
|
|
|
text-align: center;
|
|
|
|
color: #fff;
|
|
|
|
|
|
|
|
&:empty {
|
|
|
|
display: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-25 23:40:13 +00:00
|
|
|
|
2023-01-10 05:16:59 +00:00
|
|
|
.t_follow, .t_followRequestAccepted, .t_receiveFollowRequest, .t_groupInvited {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36aed2;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.t_renote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.t_quote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.t_reply {
|
|
|
|
padding: 3px;
|
|
|
|
background: #007aff;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.t_mention {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.t_pollEnded {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
2023-01-21 04:14:55 +00:00
|
|
|
.t_achievementEarned {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
|
2023-01-10 05:16:59 +00:00
|
|
|
.tail {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header {
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.headerName {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
min-width: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.headerTime {
|
|
|
|
margin-left: auto;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
}
|
|
|
|
|
|
|
|
.text {
|
2023-01-16 21:22:57 +00:00
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
|
|
|
overflow: clip;
|
2023-01-10 05:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.quote {
|
|
|
|
vertical-align: super;
|
|
|
|
font-size: 50%;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
.quote:first-child {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.quote:last-child {
|
|
|
|
margin-left: 4px;
|
|
|
|
}
|
|
|
|
|
2022-12-25 23:40:13 +00:00
|
|
|
@container (max-width: 600px) {
|
2023-01-10 05:16:59 +00:00
|
|
|
.root {
|
2022-12-25 23:40:13 +00:00
|
|
|
padding: 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@container (max-width: 500px) {
|
2023-01-10 05:16:59 +00:00
|
|
|
.root {
|
2022-12-25 23:40:13 +00:00
|
|
|
padding: 12px;
|
|
|
|
font-size: 0.85em;
|
|
|
|
}
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
</style>
|