forked from FoundKeyGang/FoundKey
client: display move notification
This commit is contained in:
parent
abfba2699e
commit
d7db1bc34e
BIN
packages/backend/assets/notification-badges/suitcase-solid.png
Normal file
BIN
packages/backend/assets/notification-badges/suitcase-solid.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -15,6 +15,7 @@
|
|||
<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>
|
||||
<i v-else-if="notification.type === 'pollEnded'" class="fas fa-poll-h"></i>
|
||||
<i v-else-if="notification.type === 'move'" class="fas fa-suitcase"></i>
|
||||
<!-- notification.reaction が null になることはまずないが、ここでoptional chaining使うと一部ブラウザで刺さるので念の為 -->
|
||||
<MkEmoji
|
||||
v-else-if="notification.type === 'reaction'"
|
||||
|
@ -63,10 +64,27 @@
|
|||
<Mfm :text="getNoteSummary(notification.note)" :plain="true" :nowrap="!full" :custom-emojis="notification.note.emojis"/>
|
||||
<i class="fas fa-quote-right"></i>
|
||||
</MkA>
|
||||
<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 === '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>
|
||||
<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>
|
||||
<span v-if="notification.type === 'move'" class="text" style="opacity: 0.6;">
|
||||
{{ i18n.ts.moved }}
|
||||
<div v-if="full"><MkFollowButton :user="notification.moveTarget" :full="true"/></div>
|
||||
</span>
|
||||
<span v-if="notification.type === 'app'" class="text">
|
||||
<Mfm :text="notification.body" :nowrap="!full"/>
|
||||
</span>
|
||||
|
|
|
@ -218,6 +218,20 @@ async function composeNotification<K extends keyof pushNotificationDataMap>(data
|
|||
],
|
||||
}];
|
||||
|
||||
case 'move':
|
||||
return [t('_notification.moved', { name: getUserName(data.body.user) }), {
|
||||
body: getUserName(data.body.moveTarget),
|
||||
icon: data.body.moveTarget.avatarUrl,
|
||||
badge: iconUrl('suitcase'),
|
||||
data,
|
||||
action: [
|
||||
{
|
||||
action: 'accept',
|
||||
title: t('follow'),
|
||||
},
|
||||
],
|
||||
}];
|
||||
|
||||
case 'app':
|
||||
return [data.body.header || data.body.body, {
|
||||
body: data.body.header && data.body.body,
|
||||
|
|
|
@ -104,6 +104,9 @@ self.addEventListener('notificationclick', <K extends keyof pushNotificationData
|
|||
case 'groupInvited':
|
||||
await swos.api('users/groups/invitations/accept', id, { invitationId: data.body.invitation.id });
|
||||
break;
|
||||
case 'move':
|
||||
await swos.api('following/create', id, { userId: data.body.moveTarget.id });
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'reject':
|
||||
|
|
Loading…
Reference in a new issue