2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2020-05-10 10:12:19 +02:00
|
|
|
<div class="qglefbjs" :class="notification.type" v-size="[{ max: 500 }, { max: 600 }]">
|
2020-01-29 20:37:25 +01:00
|
|
|
<div class="head">
|
2020-03-28 10:07:41 +01:00
|
|
|
<mk-avatar v-if="notification.user" class="icon" :user="notification.user"/>
|
|
|
|
<img v-else class="icon" :src="notification.icon" alt=""/>
|
|
|
|
<div class="sub-icon" :class="notification.type">
|
2020-01-29 20:37:25 +01:00
|
|
|
<fa :icon="faPlus" v-if="notification.type === 'follow'"/>
|
2020-03-28 10:07:41 +01:00
|
|
|
<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'"/>
|
2020-05-10 10:19:41 +02:00
|
|
|
<fa :icon="faPollH" v-else-if="notification.type === 'pollVote'"/>
|
|
|
|
<x-reaction-icon v-else-if="notification.type === 'reaction'" :reaction="notification.reaction" :custom-emojis="notification.note.emojis" :no-style="true"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="tail">
|
|
|
|
<header>
|
2020-03-28 10:07:41 +01:00
|
|
|
<router-link v-if="notification.user" class="name" :to="notification.user | userPage" v-user-preview="notification.user.id"><mk-user-name :user="notification.user"/></router-link>
|
|
|
|
<span v-else>{{ notification.header }}</span>
|
2020-01-29 20:37:25 +01:00
|
|
|
<mk-time :time="notification.createdAt" v-if="withTime"/>
|
|
|
|
</header>
|
|
|
|
<router-link v-if="notification.type === 'reaction'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
|
|
|
|
<fa :icon="faQuoteLeft"/>
|
2020-01-31 03:38:52 +01:00
|
|
|
<mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
<fa :icon="faQuoteRight"/>
|
|
|
|
</router-link>
|
|
|
|
<router-link v-if="notification.type === 'renote'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note.renote)">
|
|
|
|
<fa :icon="faQuoteLeft"/>
|
2020-01-31 03:38:52 +01:00
|
|
|
<mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.renote.emojis"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
<fa :icon="faQuoteRight"/>
|
|
|
|
</router-link>
|
|
|
|
<router-link v-if="notification.type === 'reply'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
|
2020-01-31 03:38:52 +01:00
|
|
|
<mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</router-link>
|
|
|
|
<router-link v-if="notification.type === 'mention'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
|
2020-01-31 03:38:52 +01:00
|
|
|
<mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</router-link>
|
|
|
|
<router-link v-if="notification.type === 'quote'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
|
2020-01-31 03:38:52 +01:00
|
|
|
<mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</router-link>
|
2020-05-10 10:19:41 +02:00
|
|
|
<router-link v-if="notification.type === 'pollVote'" class="text" :to="notification.note | notePage" :title="getNoteSummary(notification.note)">
|
|
|
|
<fa :icon="faQuoteLeft"/>
|
|
|
|
<mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
|
|
|
<fa :icon="faQuoteRight"/>
|
|
|
|
</router-link>
|
2020-01-31 03:58:59 +01:00
|
|
|
<span v-if="notification.type === 'follow'" class="text" style="opacity: 0.6;">{{ $t('youGotNewFollower') }}<div v-if="full"><mk-follow-button :user="notification.user" :full="true"/></div></span>
|
2020-01-29 20:37:25 +01:00
|
|
|
<span v-if="notification.type === 'followRequestAccepted'" class="text" style="opacity: 0.6;">{{ $t('followRequestAccepted') }}</span>
|
2020-01-31 03:38:52 +01:00
|
|
|
<span v-if="notification.type === 'receiveFollowRequest'" class="text" style="opacity: 0.6;">{{ $t('receiveFollowRequest') }}<div v-if="full && !followRequestDone"><button class="_textButton" @click="acceptFollowRequest()">{{ $t('accept') }}</button> | <button class="_textButton" @click="rejectFollowRequest()">{{ $t('reject') }}</button></div></span>
|
2020-02-12 18:17:54 +01:00
|
|
|
<span v-if="notification.type === 'groupInvited'" class="text" style="opacity: 0.6;">{{ $t('groupInvited') }}: <b>{{ notification.invitation.group.name }}</b><div v-if="full && !groupInviteDone"><button class="_textButton" @click="acceptGroupInvitation()">{{ $t('accept') }}</button> | <button class="_textButton" @click="rejectGroupInvitation()">{{ $t('reject') }}</button></div></span>
|
2020-03-28 10:07:41 +01:00
|
|
|
<span v-if="notification.type === 'app'" class="text">
|
|
|
|
<mfm :text="notification.body" :nowrap="!full"/>
|
|
|
|
</span>
|
2020-01-29 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-05-10 10:19:41 +02:00
|
|
|
import { faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faCheck, faPollH } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 20:37:25 +01:00
|
|
|
import { faClock } from '@fortawesome/free-regular-svg-icons';
|
2020-05-23 06:19:31 +02:00
|
|
|
import noteSummary from '../../misc/get-note-summary';
|
2020-01-29 20:37:25 +01:00
|
|
|
import XReactionIcon from './reaction-icon.vue';
|
2020-01-31 03:35:18 +01:00
|
|
|
import MkFollowButton from './follow-button.vue';
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
2020-01-31 03:35:18 +01:00
|
|
|
XReactionIcon, MkFollowButton
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
notification: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
withTime: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
2020-01-31 03:38:52 +01:00
|
|
|
full: {
|
2020-01-29 20:37:25 +01:00
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
2020-01-31 03:38:52 +01:00
|
|
|
default: false,
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2020-05-23 06:19:31 +02:00
|
|
|
getNoteSummary: (text: string) => noteSummary(text, this.$root.i18n.messages[this.$root.i18n.locale]),
|
2020-01-29 20:37:25 +01:00
|
|
|
followRequestDone: false,
|
2020-02-12 18:17:54 +01:00
|
|
|
groupInviteDone: false,
|
2020-05-26 07:34:49 +02:00
|
|
|
readObserver: new IntersectionObserver((entries, observer) => {
|
|
|
|
if (!entries.some(entry => entry.isIntersecting)) return;
|
|
|
|
this.$root.stream.send('readNotification', {
|
|
|
|
id: this.notification.id
|
|
|
|
});
|
|
|
|
entries.map(({ target }) => observer.unobserve(target));
|
|
|
|
}),
|
2020-05-10 10:19:41 +02:00
|
|
|
faIdCardAlt, faPlus, faQuoteLeft, faQuoteRight, faRetweet, faReply, faAt, faClock, faCheck, faPollH
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
},
|
2020-05-26 07:34:49 +02:00
|
|
|
|
|
|
|
mounted() {
|
|
|
|
if (!this.notification.isRead) this.readObserver.observe(this.$el);
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeDestroy() {
|
|
|
|
if (!this.notification.isRead) this.readObserver.unobserve(this.$el);
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
methods: {
|
|
|
|
acceptFollowRequest() {
|
|
|
|
this.followRequestDone = true;
|
|
|
|
this.$root.api('following/requests/accept', { userId: this.notification.user.id });
|
|
|
|
},
|
|
|
|
rejectFollowRequest() {
|
|
|
|
this.followRequestDone = true;
|
|
|
|
this.$root.api('following/requests/reject', { userId: this.notification.user.id });
|
|
|
|
},
|
2020-02-12 18:17:54 +01:00
|
|
|
acceptGroupInvitation() {
|
|
|
|
this.groupInviteDone = true;
|
|
|
|
this.$root.api('users/groups/invitations/accept', { invitationId: this.notification.invitation.id });
|
|
|
|
this.$root.dialog({
|
|
|
|
type: 'success',
|
|
|
|
iconOnly: true, autoClose: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
rejectGroupInvitation() {
|
|
|
|
this.groupInviteDone = true;
|
|
|
|
this.$root.api('users/groups/invitations/reject', { invitationId: this.notification.invitation.id });
|
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2020-05-10 10:12:19 +02:00
|
|
|
.qglefbjs {
|
2020-01-29 20:37:25 +01:00
|
|
|
position: relative;
|
|
|
|
box-sizing: border-box;
|
2020-02-18 23:00:44 +01:00
|
|
|
padding: 24px 32px;
|
2020-01-29 20:37:25 +01:00
|
|
|
font-size: 0.9em;
|
|
|
|
overflow-wrap: break-word;
|
|
|
|
display: flex;
|
|
|
|
|
2020-02-18 22:41:30 +01:00
|
|
|
&.max-width_600px {
|
|
|
|
padding: 16px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.max-width_500px {
|
2020-01-29 20:37:25 +01: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 10:07:41 +01:00
|
|
|
> .icon {
|
2020-01-29 20:37:25 +01:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
border-radius: 6px;
|
|
|
|
}
|
|
|
|
|
2020-03-28 10:07:41 +01:00
|
|
|
> .sub-icon {
|
2020-01-29 20:37:25 +01: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 10:07:41 +01:00
|
|
|
&:empty {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
> * {
|
|
|
|
color: #fff;
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
2020-02-12 18:17:54 +01:00
|
|
|
&.follow, &.followRequestAccepted, &.receiveFollowRequest, &.groupInvited {
|
2020-01-29 20:37:25 +01:00
|
|
|
padding: 3px;
|
|
|
|
background: #36aed2;
|
|
|
|
}
|
|
|
|
|
2020-02-16 12:21:05 +01:00
|
|
|
&.renote {
|
2020-01-29 20:37:25 +01:00
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.quote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #36d298;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.reply {
|
|
|
|
padding: 3px;
|
|
|
|
background: #007aff;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.mention {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
}
|
2020-05-10 10:19:41 +02:00
|
|
|
|
|
|
|
&.pollVote {
|
|
|
|
padding: 3px;
|
|
|
|
background: #88a6b7;
|
|
|
|
}
|
2020-01-29 20:37:25 +01: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;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .mk-time {
|
|
|
|
margin-left: auto;
|
|
|
|
font-size: 0.9em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .text {
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
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>
|