2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-08-09 06:51:02 +00:00
|
|
|
<div class="qglefbjs" :class="notification.type" v-size="{ max: [500, 600] }">
|
2020-01-29 19:37:25 +00:00
|
|
|
<div class="head">
|
2020-10-17 11:12:00 +00:00
|
|
|
<MkAvatar v-if="notification.user" class="icon" :user="notification.user"/>
|
|
|
|
<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">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faPlus" v-if="notification.type === 'follow'"/>
|
|
|
|
<Fa :icon="faClock" v-else-if="notification.type === 'receiveFollowRequest'"/>
|
|
|
|
<Fa :icon="faCheck" v-else-if="notification.type === 'followRequestAccepted'"/>
|
|
|
|
<Fa :icon="faIdCardAlt" v-else-if="notification.type === 'groupInvited'"/>
|
|
|
|
<Fa :icon="faRetweet" v-else-if="notification.type === 'renote'"/>
|
|
|
|
<Fa :icon="faReply" v-else-if="notification.type === 'reply'"/>
|
|
|
|
<Fa :icon="faAt" v-else-if="notification.type === 'mention'"/>
|
|
|
|
<Fa :icon="faQuoteLeft" v-else-if="notification.type === 'quote'"/>
|
|
|
|
<Fa :icon="faPollH" v-else-if="notification.type === 'pollVote'"/>
|
|
|
|
<XReactionIcon v-else-if="notification.type === 'reaction'" :reaction="notification.reaction" :custom-emojis="notification.note.emojis" :no-style="true"/>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="tail">
|
|
|
|
<header>
|
2020-10-24 16:21:41 +00:00
|
|
|
<MkA v-if="notification.user" class="name" :to="userPage(notification.user)" v-user-preview="notification.user.id"><MkUserName :user="notification.user"/></MkA>
|
2020-03-28 09:07:41 +00:00
|
|
|
<span v-else>{{ notification.header }}</span>
|
2020-10-27 09:11:41 +00:00
|
|
|
<MkTime :time="notification.createdAt" v-if="withTime" 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)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faQuoteLeft"/>
|
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
|
|
|
<Fa :icon="faQuoteRight"/>
|
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)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faQuoteLeft"/>
|
|
|
|
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.renote.emojis"/>
|
|
|
|
<Fa :icon="faQuoteRight"/>
|
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)">
|
2020-10-17 11:12:00 +00:00
|
|
|
<Fa :icon="faQuoteLeft"/>
|
|
|
|
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
|
|
|
<Fa :icon="faQuoteRight"/>
|
2020-10-24 16:21:41 +00:00
|
|
|
</MkA>
|
2020-12-26 01:47:36 +00: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 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>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2020-05-10 08:19:41 +00:00
|
|
|
import { faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faCheck, faPollH } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 19:37:25 +00:00
|
|
|
import { faClock } from '@fortawesome/free-regular-svg-icons';
|
2020-12-28 14:05:30 +00:00
|
|
|
import { getNoteSummary } from '../../misc/get-note-summary';
|
2020-01-29 19:37:25 +00:00
|
|
|
import XReactionIcon from './reaction-icon.vue';
|
2020-01-31 02:35:18 +00:00
|
|
|
import MkFollowButton from './follow-button.vue';
|
2020-10-17 11:12:00 +00:00
|
|
|
import notePage from '../filters/note';
|
|
|
|
import { userPage } from '../filters/user';
|
2020-12-28 14:05:30 +00:00
|
|
|
import { i18n } from '@/i18n';
|
2020-10-17 11:12:00 +00:00
|
|
|
import * as os from '@/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
2020-01-31 02:35:18 +00:00
|
|
|
XReactionIcon, MkFollowButton
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
notification: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
withTime: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-01-31 02:38:52 +00:00
|
|
|
full: {
|
2020-01-29 19:37:25 +00:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2020-01-31 02:38:52 +00:00
|
|
|
default: false,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-12-28 14:05:30 +00:00
|
|
|
getNoteSummary: (text: string) => getNoteSummary(text, i18n.locale),
|
2020-01-29 19:37:25 +00:00
|
|
|
followRequestDone: false,
|
2020-02-12 17:17:54 +00:00
|
|
|
groupInviteDone: false,
|
2020-05-26 06:00:15 +00:00
|
|
|
connection: null,
|
2020-05-31 05:57:22 +00:00
|
|
|
readObserver: null,
|
|
|
|
faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faClock, faCheck, faPollH
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-06-03 04:42:26 +00:00
|
|
|
if (!this.notification.isRead) {
|
2020-05-31 05:57:22 +00:00
|
|
|
this.readObserver = new IntersectionObserver((entries, observer) => {
|
2020-05-26 05:34:49 +00:00
|
|
|
if (!entries.some(entry => entry.isIntersecting)) return;
|
2020-10-17 11:12:00 +00:00
|
|
|
os.stream.send('readNotification', {
|
2020-05-26 05:34:49 +00:00
|
|
|
id: this.notification.id
|
|
|
|
});
|
|
|
|
entries.map(({ target }) => observer.unobserve(target));
|
2020-06-03 04:42:32 +00:00
|
|
|
});
|
2020-05-26 05:34:49 +00:00
|
|
|
|
2020-05-26 06:00:15 +00:00
|
|
|
this.readObserver.observe(this.$el);
|
2020-05-31 05:57:22 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
this.connection = os.stream.useSharedConnection('main');
|
2020-05-26 06:00:15 +00:00
|
|
|
this.connection.on('readAllNotifications', () => this.readObserver.unobserve(this.$el));
|
|
|
|
}
|
2020-05-26 05:34:49 +00:00
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
beforeUnmount() {
|
2020-05-26 06:04:44 +00:00
|
|
|
if (!this.notification.isRead) {
|
|
|
|
this.readObserver.unobserve(this.$el);
|
|
|
|
this.connection.dispose();
|
|
|
|
}
|
2020-05-26 05:34:49 +00:00
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
methods: {
|
|
|
|
acceptFollowRequest() {
|
|
|
|
this.followRequestDone = true;
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('following/requests/accept', { userId: this.notification.user.id });
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
rejectFollowRequest() {
|
|
|
|
this.followRequestDone = true;
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('following/requests/reject', { userId: this.notification.user.id });
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
2020-02-12 17:17:54 +00:00
|
|
|
acceptGroupInvitation() {
|
|
|
|
this.groupInviteDone = true;
|
2020-10-17 11:12:00 +00:00
|
|
|
os.apiWithDialog('users/groups/invitations/accept', { invitationId: this.notification.invitation.id });
|
2020-02-12 17:17:54 +00:00
|
|
|
},
|
|
|
|
rejectGroupInvitation() {
|
|
|
|
this.groupInviteDone = true;
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('users/groups/invitations/reject', { invitationId: this.notification.invitation.id });
|
2020-02-12 17:17:54 +00:00
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
notePage,
|
|
|
|
userPage
|
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;
|
|
|
|
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 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;
|
|
|
|
pointer-events: none;
|
|
|
|
|
2020-03-28 09:07:41 +00:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
> * {
|
|
|
|
color: #fff;
|
|
|
|
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;
|
|
|
|
background: #36aed2;
|
|
|
|
}
|
|
|
|
|
2020-02-16 11:21:05 +00:00
|
|
|
&.renote {
|
2020-01-29 19:37:25 +00:00
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.quote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.reply {
|
|
|
|
padding: 3px;
|
|
|
|
background: #007aff;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.mention {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
}
|
2020-05-10 08:19:41 +00:00
|
|
|
|
|
|
|
&.pollVote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
}
|
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-02-27 02:18:53 +00:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
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-02-27 02:18:53 +00:00
|
|
|
overflow: hidden; // overflow: clip; をSafariが対応したら消す
|
|
|
|
overflow: clip;
|
2020-01-29 19:37:25 +00:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
|
|
> [data-icon] {
|
|
|
|
vertical-align: super;
|
|
|
|
font-size: 50%;
|
|
|
|
opacity: 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
> [data-icon]:first-child {
|
|
|
|
margin-right: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> [data-icon]:last-child {
|
|
|
|
margin-left: 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|