2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
2021-11-19 02:36:12 -08:00
|
|
|
<div ref="elRef" v-size="{ max: [500, 600] }" class="qglefbjs" :class="notification.type">
|
2020-01-29 11:37:25 -08:00
|
|
|
<div class="head">
|
2022-03-05 23:06:27 -08: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 04:12:00 -07:00
|
|
|
<img v-else-if="notification.icon" class="icon" :src="notification.icon" alt=""/>
|
2020-03-28 02:07:41 -07:00
|
|
|
<div class="sub-icon" :class="notification.type">
|
2021-04-20 07:22:59 -07:00
|
|
|
<i v-if="notification.type === 'follow'" class="fas fa-plus"></i>
|
|
|
|
<i v-else-if="notification.type === 'receiveFollowRequest'" class="fas fa-clock"></i>
|
|
|
|
<i v-else-if="notification.type === 'followRequestAccepted'" class="fas fa-check"></i>
|
|
|
|
<i v-else-if="notification.type === 'groupInvited'" class="fas fa-id-card-alt"></i>
|
|
|
|
<i v-else-if="notification.type === 'renote'" class="fas fa-retweet"></i>
|
|
|
|
<i v-else-if="notification.type === 'reply'" class="fas fa-reply"></i>
|
|
|
|
<i v-else-if="notification.type === 'mention'" class="fas fa-at"></i>
|
|
|
|
<i v-else-if="notification.type === 'quote'" class="fas fa-quote-left"></i>
|
|
|
|
<i v-else-if="notification.type === 'pollVote'" class="fas fa-poll-h"></i>
|
2022-03-05 23:06:27 -08:00
|
|
|
<i v-else-if="notification.type === 'pollEnded'" class="fas fa-poll-h"></i>
|
2021-10-22 10:44:52 -07:00
|
|
|
<!-- notification.reaction が null になることはまずないが、ここでoptional chaining使うと一部ブラウザで刺さるので念の為 -->
|
2021-11-07 10:38:48 -08:00
|
|
|
<XReactionIcon v-else-if="notification.type === 'reaction'"
|
2021-11-19 02:36:12 -08:00
|
|
|
ref="reactionRef"
|
2021-11-07 10:38:48 -08:00
|
|
|
:reaction="notification.reaction ? notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : notification.reaction"
|
|
|
|
:custom-emojis="notification.note.emojis"
|
|
|
|
:no-style="true"
|
|
|
|
/>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="tail">
|
|
|
|
<header>
|
2022-03-05 23:06:27 -08: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 02:07:41 -07:00
|
|
|
<span v-else>{{ notification.header }}</span>
|
2021-11-19 02:36:12 -08:00
|
|
|
<MkTime v-if="withTime" :time="notification.createdAt" class="time"/>
|
2020-01-29 11:37:25 -08:00
|
|
|
</header>
|
2020-10-24 09:21:41 -07:00
|
|
|
<MkA v-if="notification.type === 'reaction'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-left"></i>
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-right"></i>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'renote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-left"></i>
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.renote.emojis"/>
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-right"></i>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'reply'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'mention'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'quote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
|
|
|
<MkA v-if="notification.type === 'pollVote'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-left"></i>
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2021-04-20 07:22:59 -07:00
|
|
|
<i class="fas fa-quote-right"></i>
|
2020-10-24 09:21:41 -07:00
|
|
|
</MkA>
|
2022-03-05 23:06:27 -08:00
|
|
|
<MkA v-if="notification.type === 'pollEnded'" class="text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
|
|
|
<i class="fas fa-quote-left"></i>
|
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
|
|
|
<i class="fas fa-quote-right"></i>
|
|
|
|
</MkA>
|
2020-12-25 17:47:36 -08:00
|
|
|
<span v-if="notification.type === 'follow'" class="text" style="opacity: 0.6;">{{ $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;">{{ $ts.followRequestAccepted }}</span>
|
|
|
|
<span v-if="notification.type === 'receiveFollowRequest'" class="text" style="opacity: 0.6;">{{ $ts.receiveFollowRequest }}<div v-if="full && !followRequestDone"><button class="_textButton" @click="acceptFollowRequest()">{{ $ts.accept }}</button> | <button class="_textButton" @click="rejectFollowRequest()">{{ $ts.reject }}</button></div></span>
|
|
|
|
<span v-if="notification.type === 'groupInvited'" class="text" style="opacity: 0.6;">{{ $ts.groupInvited }}: <b>{{ notification.invitation.group.name }}</b><div v-if="full && !groupInviteDone"><button class="_textButton" @click="acceptGroupInvitation()">{{ $ts.accept }}</button> | <button class="_textButton" @click="rejectGroupInvitation()">{{ $ts.reject }}</button></div></span>
|
2020-03-28 02:07:41 -07:00
|
|
|
<span v-if="notification.type === 'app'" class="text">
|
2020-10-17 04:12:00 -07:00
|
|
|
<Mfm :text="notification.body" :nowrap="!full"/>
|
2020-03-28 02:07:41 -07:00
|
|
|
</span>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-04-30 05:52:07 -07:00
|
|
|
import { defineComponent, ref, onMounted, onUnmounted, watch } from 'vue';
|
2021-11-12 04:29:59 -08:00
|
|
|
import * as misskey from 'misskey-js';
|
2021-11-11 09:02:25 -08:00
|
|
|
import { getNoteSummary } from '@/scripts/get-note-summary';
|
2020-01-29 11:37:25 -08:00
|
|
|
import XReactionIcon from './reaction-icon.vue';
|
2020-01-30 18:35:18 -08:00
|
|
|
import MkFollowButton from './follow-button.vue';
|
2021-11-07 10:38:48 -08:00
|
|
|
import XReactionTooltip from './reaction-tooltip.vue';
|
2021-11-28 03:29:37 -08:00
|
|
|
import { notePage } from '@/filters/note';
|
2021-11-11 09:02:25 -08:00
|
|
|
import { userPage } from '@/filters/user';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import * as os from '@/os';
|
2021-12-29 05:13:09 -08:00
|
|
|
import { stream } from '@/stream';
|
2021-11-12 06:53:10 -08:00
|
|
|
import { useTooltip } from '@/scripts/use-tooltip';
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
export default defineComponent({
|
2020-01-29 11:37:25 -08:00
|
|
|
components: {
|
2020-01-30 18:35:18 -08:00
|
|
|
XReactionIcon, MkFollowButton
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
2021-11-07 10:38:48 -08:00
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
props: {
|
|
|
|
notification: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
withTime: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-01-30 18:38:52 -08:00
|
|
|
full: {
|
2020-01-29 11:37:25 -08:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2020-01-30 18:38:52 -08:00
|
|
|
default: false,
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
},
|
2020-05-30 22:57:22 -07:00
|
|
|
|
2021-11-07 10:38:48 -08:00
|
|
|
setup(props) {
|
|
|
|
const elRef = ref<HTMLElement>(null);
|
|
|
|
const reactionRef = ref(null);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (!props.notification.isRead) {
|
2021-11-25 20:43:11 -08:00
|
|
|
const readObserver = new IntersectionObserver((entries, observer) => {
|
2021-11-07 10:38:48 -08:00
|
|
|
if (!entries.some(entry => entry.isIntersecting)) return;
|
2021-12-29 05:13:09 -08:00
|
|
|
stream.send('readNotification', {
|
2021-11-07 10:38:48 -08:00
|
|
|
id: props.notification.id
|
|
|
|
});
|
2021-11-25 20:43:11 -08:00
|
|
|
observer.disconnect();
|
2020-05-25 22:34:49 -07:00
|
|
|
});
|
2021-11-07 10:38:48 -08:00
|
|
|
|
|
|
|
readObserver.observe(elRef.value);
|
|
|
|
|
2021-12-29 05:13:09 -08:00
|
|
|
const connection = stream.useChannel('main');
|
2021-11-25 20:43:11 -08:00
|
|
|
connection.on('readAllNotifications', () => readObserver.disconnect());
|
2021-11-07 10:38:48 -08:00
|
|
|
|
2022-04-30 05:52:07 -07:00
|
|
|
watch(props.notification.isRead, () => {
|
|
|
|
readObserver.disconnect();
|
|
|
|
});
|
|
|
|
|
2021-11-25 20:43:11 -08:00
|
|
|
onUnmounted(() => {
|
|
|
|
readObserver.disconnect();
|
|
|
|
connection.dispose();
|
|
|
|
});
|
|
|
|
}
|
2021-11-07 10:38:48 -08:00
|
|
|
});
|
2020-05-25 22:34:49 -07:00
|
|
|
|
2021-11-07 10:38:48 -08:00
|
|
|
const followRequestDone = ref(false);
|
|
|
|
const groupInviteDone = ref(false);
|
2020-05-30 22:57:22 -07:00
|
|
|
|
2021-11-07 10:38:48 -08:00
|
|
|
const acceptFollowRequest = () => {
|
|
|
|
followRequestDone.value = true;
|
|
|
|
os.api('following/requests/accept', { userId: props.notification.user.id });
|
|
|
|
};
|
2020-05-25 22:34:49 -07:00
|
|
|
|
2021-11-07 10:38:48 -08:00
|
|
|
const rejectFollowRequest = () => {
|
|
|
|
followRequestDone.value = true;
|
|
|
|
os.api('following/requests/reject', { userId: props.notification.user.id });
|
|
|
|
};
|
2020-05-25 22:34:49 -07:00
|
|
|
|
2021-11-07 10:38:48 -08:00
|
|
|
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 });
|
|
|
|
};
|
|
|
|
|
2021-12-05 03:01:52 -08:00
|
|
|
useTooltip(reactionRef, (showing) => {
|
2021-11-07 10:38:48 -08:00
|
|
|
os.popup(XReactionTooltip, {
|
|
|
|
showing,
|
|
|
|
reaction: props.notification.reaction ? props.notification.reaction.replace(/^:(\w+):$/, ':$1@.:') : props.notification.reaction,
|
|
|
|
emojis: props.notification.note.emojis,
|
2022-01-31 04:07:33 -08:00
|
|
|
targetElement: reactionRef.value.$el,
|
2021-11-07 10:38:48 -08:00
|
|
|
}, {}, 'closed');
|
2021-11-12 06:53:10 -08:00
|
|
|
});
|
2021-11-07 10:38:48 -08:00
|
|
|
|
|
|
|
return {
|
2021-11-12 04:29:59 -08:00
|
|
|
getNoteSummary: (note: misskey.entities.Note) => getNoteSummary(note),
|
2021-11-07 10:38:48 -08:00
|
|
|
followRequestDone,
|
|
|
|
groupInviteDone,
|
|
|
|
notePage,
|
|
|
|
userPage,
|
|
|
|
acceptFollowRequest,
|
|
|
|
rejectFollowRequest,
|
|
|
|
acceptGroupInvitation,
|
|
|
|
rejectGroupInvitation,
|
|
|
|
elRef,
|
|
|
|
reactionRef,
|
2022-03-05 23:06:27 -08:00
|
|
|
i18n,
|
2021-11-07 10:38:48 -08:00
|
|
|
};
|
|
|
|
},
|
2020-01-29 11:37:25 -08:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-05-10 01:12:19 -07:00
|
|
|
.qglefbjs {
|
2020-01-29 11:37:25 -08:00
|
|
|
position: relative;
|
|
|
|
box-sizing: border-box;
|
2020-02-18 14:00:44 -08:00
|
|
|
padding: 24px 32px;
|
2020-01-29 11:37:25 -08:00
|
|
|
font-size: 0.9em;
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
display: flex;
|
2020-10-17 04:12:00 -07:00
|
|
|
contain: content;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-02-18 13:41:30 -08:00
|
|
|
&.max-width_600px {
|
|
|
|
padding: 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.max-width_500px {
|
2020-01-29 11:37:25 -08:00
|
|
|
padding: 12px;
|
|
|
|
font-size: 0.8em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
clear: both;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .head {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
flex-shrink: 0;
|
|
|
|
width: 42px;
|
|
|
|
height: 42px;
|
|
|
|
margin-right: 8px;
|
|
|
|
|
2020-03-28 02:07:41 -07:00
|
|
|
> .icon {
|
2020-01-29 11:37:25 -08:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
|
|
|
|
2020-03-28 02:07:41 -07:00
|
|
|
> .sub-icon {
|
2020-01-29 11:37:25 -08: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 06:17:51 -08:00
|
|
|
text-align: center;
|
2020-01-29 11:37:25 -08:00
|
|
|
|
2020-03-28 02:07:41 -07:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
> * {
|
|
|
|
color: #fff;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2020-02-12 09:17:54 -08:00
|
|
|
&.follow, &.followRequestAccepted, &.receiveFollowRequest, &.groupInvited {
|
2020-01-29 11:37:25 -08:00
|
|
|
padding: 3px;
|
|
|
|
background: #36aed2;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
2020-02-16 03:21:05 -08:00
|
|
|
&.renote {
|
2020-01-29 11:37:25 -08:00
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
&.quote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
&.reply {
|
|
|
|
padding: 3px;
|
|
|
|
background: #007aff;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
&.mention {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
2020-05-10 01:19:41 -07:00
|
|
|
|
|
|
|
&.pollVote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
2021-11-07 06:17:51 -08:00
|
|
|
pointer-events: none;
|
2020-05-10 01:19:41 -07:00
|
|
|
}
|
2022-03-05 23:06:27 -08:00
|
|
|
|
|
|
|
&.pollEnded {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
2020-01-29 11:37:25 -08: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 05:57:16 -08:00
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
|
2020-10-27 02:11:41 -07:00
|
|
|
> .time {
|
2020-01-29 11:37:25 -08:00
|
|
|
margin-left: auto;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
white-space: nowrap;
|
2021-03-02 05:57:16 -08:00
|
|
|
overflow: hidden;
|
2020-01-29 11:37:25 -08:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
2021-04-20 07:22:59 -07:00
|
|
|
> i {
|
2020-01-29 11:37:25 -08:00
|
|
|
vertical-align: super;
|
|
|
|
font-size: 50%;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
|
2021-04-20 07:22:59 -07:00
|
|
|
> i:first-child {
|
2020-01-29 11:37:25 -08:00
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
|
2021-04-20 07:22:59 -07:00
|
|
|
> i:last-child {
|
2020-01-29 11:37:25 -08:00
|
|
|
margin-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|