2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2021-11-19 10:36:12 +00:00
|
|
|
<div ref="elRef" v-size="{ max: [500, 600] }" class="qglefbjs" :class="notification.type">
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="head">
|
2022-03-06 07:06:27 +00:00
|
|
|
<MkAvatar v-if="notification.type === 'pollEnded'" class="icon" :user="notification.note.user"/>
|
|
|
|
<MkAvatar v-else-if="notification.user" class="icon" :user="notification.user"/>
|
2020-10-17 11:12:00 +00:00
|
|
|
<img v-else-if="notification.icon" class="icon" :src="notification.icon" alt=""/>
|
2020-03-28 09:07:41 +00:00
|
|
|
<div class="sub-icon" :class="notification.type">
|
2022-11-07 03:29:42 +00:00
|
|
|
<i v-if="notification.type === 'follow'" class="ph-plus-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'receiveFollowRequest'" class="ph-clock-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'followRequestAccepted'" class="ph-check-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'groupInvited'" class="ph-identification-card-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'renote'" class="ph-repeat-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'reply'" class="ph-arrow-bend-up-left-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'mention'" class="ph-at-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'quote'" class="ph-quotes-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'pollVote'" class="ph-microphone-stage-bold"></i>
|
|
|
|
<i v-else-if="notification.type === 'pollEnded'" class="ph-microphone-stage-bold"></i>
|
2021-10-22 17:44:52 +00:00
|
|
|
<!-- notification.reaction が null になることはまずないが、ここでoptional chaining使うと一部ブラウザで刺さるので念の為 -->
|
2022-06-05 03:26:36 +00:00
|
|
|
<XReactionIcon
|
|
|
|
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"
|
|
|
|
/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="tail">
|
|
|
|
<header>
|
2022-03-06 07:06:27 +00:00
|
|
|
<span v-if="notification.type === 'pollEnded'">{{ i18n.ts._notification.pollEnded }}</span>
|
|
|
|
<MkA v-else-if="notification.user" v-user-preview="notification.user.id" class="name" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
|
2020-03-28 09:07:41 +00:00
|
|
|
<span v-else>{{ notification.header }}</span>
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkTime v-if="withTime" :time="notification.createdAt" class="time"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</header>
|
2020-10-24 16:21:41 +00:00
|
|
|
<MkA v-if="notification.type === 'reaction'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'renote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.renote.emojis"/>
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'reply'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'mention'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'quote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'pollVote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
2022-03-06 07:06:27 +00:00
|
|
|
<MkA v-if="notification.type === 'pollEnded'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2022-03-06 07:06:27 +00:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2022-11-07 02:49:47 +00:00
|
|
|
<i class="ph-quotes-bold ph-lg"></i>
|
2022-03-06 07:06:27 +00:00
|
|
|
</MkA>
|
2022-07-20 13:24:26 +00:00
|
|
|
<span v-if="notification.type === 'follow'" class="text" style="opacity: 0.6;">{{ i18n.ts.youGotNewFollower }}<div v-if="full"><MkFollowButton :user="notification.user" :full="true"/></div></span>
|
|
|
|
<span v-if="notification.type === 'followRequestAccepted'" class="text" style="opacity: 0.6;">{{ i18n.ts.followRequestAccepted }}</span>
|
|
|
|
<span v-if="notification.type === 'receiveFollowRequest'" class="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-if="notification.type === 'groupInvited'" class="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>
|
2020-03-28 09:07:41 +00:00
|
|
|
<span v-if="notification.type === 'app'" class="text">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Mfm :text="notification.body" :nowrap="!full"/>
|
2020-03-28 09:07:41 +00:00
|
|
|
</span>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-06-28 05:34:44 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { ref, onMounted, onUnmounted, watch } from 'vue';
|
2021-11-12 12:29:59 +00:00
|
|
|
import * as misskey from 'misskey-js';
|
2022-08-30 15:24:33 +00:00
|
|
|
import XReactionIcon from '@/components/MkReactionIcon.vue';
|
|
|
|
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';
|
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,
|
|
|
|
});
|
|
|
|
|
|
|
|
const elRef = ref<HTMLElement>(null);
|
|
|
|
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>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-05-10 08:12:19 +00:00
|
|
|
.qglefbjs {
|
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;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-02-18 21:41:30 +00:00
|
|
|
&.max-width_600px {
|
|
|
|
padding: 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.max-width_500px {
|
2020-01-29 19:37:25 +00:00
|
|
|
padding: 12px;
|
2022-07-15 10:31:04 +00:00
|
|
|
font-size: 0.85em;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
> .head {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
flex-shrink: 0;
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
margin-right: 8px;
|
|
|
|
|
2020-03-28 09:07:41 +00:00
|
|
|
> .icon {
|
2020-01-29 19:37:25 +00:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
|
|
|
|
2020-03-28 09:07:41 +00:00
|
|
|
> .sub-icon {
|
2020-01-29 19:37:25 +00:00
|
|
|
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;
|
2021-11-07 14:17:51 +00:00
|
|
|
text-align: center;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-03-28 09:07:41 +00:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
> * {
|
2022-07-27 18:21:25 +00:00
|
|
|
color: #fff;
|
2020-01-29 19:37:25 +00:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2020-02-12 17:17:54 +00:00
|
|
|
&.follow, &.followRequestAccepted, &.receiveFollowRequest, &.groupInvited {
|
2020-01-29 19:37:25 +00:00
|
|
|
padding: 3px;
|
2022-07-27 04:18:36 +00:00
|
|
|
background: #31748f;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
2020-02-16 11:21:05 +00:00
|
|
|
&.renote {
|
2020-01-29 19:37:25 +00:00
|
|
|
padding: 3px;
|
2022-07-27 18:21:25 +00:00
|
|
|
background: #31748f;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.quote {
|
|
|
|
padding: 3px;
|
2022-07-27 18:21:25 +00:00
|
|
|
background: #31748f;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.reply {
|
|
|
|
padding: 3px;
|
2022-07-27 04:18:36 +00:00
|
|
|
background: #c4a7e7;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&.mention {
|
|
|
|
padding: 3px;
|
2022-07-27 04:18:36 +00:00
|
|
|
background: #908caa;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
2020-05-10 08:19:41 +00:00
|
|
|
|
|
|
|
&.pollVote {
|
|
|
|
padding: 3px;
|
2022-07-27 04:18:36 +00:00
|
|
|
background: #908caa;
|
2021-11-07 14:17:51 +00:00
|
|
|
pointer-events: none;
|
2020-05-10 08:19:41 +00:00
|
|
|
}
|
2022-03-06 07:06:27 +00:00
|
|
|
|
|
|
|
&.pollEnded {
|
|
|
|
padding: 3px;
|
2022-07-27 04:18:36 +00:00
|
|
|
background: #908caa;
|
2022-03-06 07:06:27 +00:00
|
|
|
pointer-events: none;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .tail {
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
|
|
|
|
> header {
|
|
|
|
display: flex;
|
|
|
|
align-items: baseline;
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
min-width: 0;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
|
2020-10-27 09:11:41 +00:00
|
|
|
> .time {
|
2020-01-29 19:37:25 +00:00
|
|
|
margin-left: auto;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
white-space: nowrap;
|
2021-03-02 13:57:16 +00:00
|
|
|
overflow: hidden;
|
2020-01-29 19:37:25 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
2021-04-20 14:22:59 +00:00
|
|
|
> i {
|
2020-01-29 19:37:25 +00:00
|
|
|
vertical-align: super;
|
|
|
|
font-size: 50%;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
|
2021-04-20 14:22:59 +00:00
|
|
|
> i:first-child {
|
2020-01-29 19:37:25 +00:00
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
|
2021-04-20 14:22:59 +00:00
|
|
|
> i:last-child {
|
2020-01-29 19:37:25 +00:00
|
|
|
margin-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|