Notifications: Reduxify.
This commit is contained in:
parent
e3cf82b3be
commit
6074f16f9b
3 changed files with 37 additions and 30 deletions
|
@ -31,7 +31,7 @@ const Notification = {
|
||||||
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
return generateProfileLink(user.id, user.screen_name, this.$store.state.instance.restrictedNicknames)
|
||||||
},
|
},
|
||||||
getUser (notification) {
|
getUser (notification) {
|
||||||
return this.$store.state.users.usersObject[notification.from_profile.id]
|
return this.$store.state.users.usersObject[notification.redux.account.id]
|
||||||
},
|
},
|
||||||
toggleMute () {
|
toggleMute () {
|
||||||
this.unmuted = !this.unmuted
|
this.unmuted = !this.unmuted
|
||||||
|
@ -57,21 +57,21 @@ const Notification = {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
userClass () {
|
userClass () {
|
||||||
return highlightClass(this.notification.from_profile)
|
return highlightClass(this.notification.redux.account)
|
||||||
},
|
},
|
||||||
userStyle () {
|
userStyle () {
|
||||||
const highlight = this.$store.getters.mergedConfig.highlight
|
const highlight = this.$store.getters.mergedConfig.highlight
|
||||||
const user = this.notification.from_profile
|
const user = this.notification.redux.account
|
||||||
return highlightStyle(highlight[user.screen_name])
|
return highlightStyle(highlight[user.screen_name])
|
||||||
},
|
},
|
||||||
user () {
|
user () {
|
||||||
return this.$store.getters.findUser(this.notification.from_profile.id)
|
return this.$store.getters.findUser(this.notification.redux.account.id)
|
||||||
},
|
},
|
||||||
userProfileLink () {
|
userProfileLink () {
|
||||||
return this.generateUserProfileLink(this.user)
|
return this.generateUserProfileLink(this.user)
|
||||||
},
|
},
|
||||||
targetUser () {
|
targetUser () {
|
||||||
return this.$store.getters.findUser(this.notification.target.id)
|
return this.$store.getters.findUser(this.notification.redux.target.id)
|
||||||
},
|
},
|
||||||
targetUserProfileLink () {
|
targetUserProfileLink () {
|
||||||
return this.generateUserProfileLink(this.targetUser)
|
return this.generateUserProfileLink(this.targetUser)
|
||||||
|
@ -80,7 +80,7 @@ const Notification = {
|
||||||
return this.$store.getters.relationship(this.user.id).muting
|
return this.$store.getters.relationship(this.user.id).muting
|
||||||
},
|
},
|
||||||
isStatusNotification () {
|
isStatusNotification () {
|
||||||
return isStatusNotification(this.notification.type)
|
return (this.notification.redux.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<status
|
<status
|
||||||
v-if="notification.type === 'mention'"
|
v-if="notification.redux.type === 'mention'"
|
||||||
:compact="true"
|
:compact="true"
|
||||||
:statusoid="notification.status"
|
:statusoid="notification.redux.status"
|
||||||
/>
|
/>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div
|
<div
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
>
|
>
|
||||||
<small>
|
<small>
|
||||||
<router-link :to="userProfileLink">
|
<router-link :to="userProfileLink">
|
||||||
{{ notification.from_profile.screen_name }}
|
{{ notification.redux.account.redux.acct }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</small>
|
</small>
|
||||||
<a
|
<a
|
||||||
|
@ -28,13 +28,13 @@
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
class="avatar-container"
|
class="avatar-container"
|
||||||
:href="notification.from_profile.statusnet_profile_url"
|
:href="notification.redux.account.redux.url"
|
||||||
@click.stop.prevent.capture="toggleUserExpanded"
|
@click.stop.prevent.capture="toggleUserExpanded"
|
||||||
>
|
>
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
:compact="true"
|
:compact="true"
|
||||||
:better-shadow="betterShadow"
|
:better-shadow="betterShadow"
|
||||||
:user="notification.from_profile"
|
:user="notification.redux.account"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
<div class="notification-right">
|
<div class="notification-right">
|
||||||
|
@ -48,44 +48,44 @@
|
||||||
<div class="name-and-action">
|
<div class="name-and-action">
|
||||||
<!-- eslint-disable vue/no-v-html -->
|
<!-- eslint-disable vue/no-v-html -->
|
||||||
<bdi
|
<bdi
|
||||||
v-if="!!notification.from_profile.name_html"
|
v-if="!!notification.redux.account.name_html"
|
||||||
class="username"
|
class="username"
|
||||||
:title="'@'+notification.from_profile.screen_name"
|
:title="'@'+notification.redux.account.screen_name"
|
||||||
v-html="notification.from_profile.name_html"
|
v-html="notification.redux.account.name_html"
|
||||||
/>
|
/>
|
||||||
<!-- eslint-enable vue/no-v-html -->
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
<span
|
<span
|
||||||
v-else
|
v-else
|
||||||
class="username"
|
class="username"
|
||||||
:title="'@'+notification.from_profile.screen_name"
|
:title="'@'+notification.redux.account.redux.acct"
|
||||||
>{{ notification.from_profile.name }}</span>
|
>{{ notification.redux.account.display_name }}</span>
|
||||||
<span v-if="notification.type === 'like'">
|
<span v-if="notification.redux.type === 'favourite'">
|
||||||
<i class="fa icon-star lit" />
|
<i class="fa icon-star lit" />
|
||||||
<small>{{ $t('notifications.favorited_you') }}</small>
|
<small>{{ $t('notifications.favorited_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'repeat'">
|
<span v-if="notification.redux.type === 'reblog'">
|
||||||
<i
|
<i
|
||||||
class="fa icon-retweet lit"
|
class="fa icon-retweet lit"
|
||||||
:title="$t('tool_tip.repeat')"
|
:title="$t('tool_tip.repeat')"
|
||||||
/>
|
/>
|
||||||
<small>{{ $t('notifications.repeated_you') }}</small>
|
<small>{{ $t('notifications.repeated_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'follow'">
|
<span v-if="notification.redux.type === 'follow'">
|
||||||
<i class="fa icon-user-plus lit" />
|
<i class="fa icon-user-plus lit" />
|
||||||
<small>{{ $t('notifications.followed_you') }}</small>
|
<small>{{ $t('notifications.followed_you') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'follow_request'">
|
<span v-if="notification.redux.type === 'follow_request'">
|
||||||
<i class="fa icon-user lit" />
|
<i class="fa icon-user lit" />
|
||||||
<small>{{ $t('notifications.follow_request') }}</small>
|
<small>{{ $t('notifications.follow_request') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'move'">
|
<span v-if="notification.redux.type === 'move'">
|
||||||
<i class="fa icon-arrow-curved lit" />
|
<i class="fa icon-arrow-curved lit" />
|
||||||
<small>{{ $t('notifications.migrated_to') }}</small>
|
<small>{{ $t('notifications.migrated_to') }}</small>
|
||||||
</span>
|
</span>
|
||||||
<span v-if="notification.type === 'pleroma:emoji_reaction'">
|
<span v-if="notification.redux.type === 'pleroma:emoji_reaction'">
|
||||||
<small>
|
<small>
|
||||||
<i18n path="notifications.reacted_with">
|
<i18n path="notifications.reacted_with">
|
||||||
<span class="emoji-reaction-emoji">{{ notification.emoji }}</span>
|
<span class="emoji-reaction-emoji">{{ notification.redux.emoji }}</span>
|
||||||
</i18n>
|
</i18n>
|
||||||
</small>
|
</small>
|
||||||
</span>
|
</span>
|
||||||
|
@ -96,11 +96,11 @@
|
||||||
>
|
>
|
||||||
<router-link
|
<router-link
|
||||||
v-if="notification.status"
|
v-if="notification.status"
|
||||||
:to="{ name: 'conversation', params: { id: notification.status.id } }"
|
:to="{ name: 'conversation', params: { id: notification.redux.status.id } }"
|
||||||
class="faint-link"
|
class="faint-link"
|
||||||
>
|
>
|
||||||
<Timeago
|
<Timeago
|
||||||
:time="notification.created_at"
|
:time="notification.redux.created_at"
|
||||||
:auto-update="240"
|
:auto-update="240"
|
||||||
/>
|
/>
|
||||||
</router-link>
|
</router-link>
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
>
|
>
|
||||||
<span class="faint">
|
<span class="faint">
|
||||||
<Timeago
|
<Timeago
|
||||||
:time="notification.created_at"
|
:time="notification.redux.created_at"
|
||||||
:auto-update="240"
|
:auto-update="240"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
@ -123,14 +123,14 @@
|
||||||
><i class="button-icon icon-eye-off" /></a>
|
><i class="button-icon icon-eye-off" /></a>
|
||||||
</span>
|
</span>
|
||||||
<div
|
<div
|
||||||
v-if="notification.type === 'follow' || notification.type === 'follow_request'"
|
v-if="notification.redux.type === 'follow' || notification.redux.type === 'follow_request'"
|
||||||
class="follow-text"
|
class="follow-text"
|
||||||
>
|
>
|
||||||
<router-link
|
<router-link
|
||||||
:to="userProfileLink"
|
:to="userProfileLink"
|
||||||
class="follow-name"
|
class="follow-name"
|
||||||
>
|
>
|
||||||
@{{ notification.from_profile.screen_name }}
|
@{{ notification.redux.account.redux.acct }}
|
||||||
</router-link>
|
</router-link>
|
||||||
<div
|
<div
|
||||||
v-if="notification.type === 'follow_request'"
|
v-if="notification.type === 'follow_request'"
|
||||||
|
@ -153,13 +153,13 @@
|
||||||
class="move-text"
|
class="move-text"
|
||||||
>
|
>
|
||||||
<router-link :to="targetUserProfileLink">
|
<router-link :to="targetUserProfileLink">
|
||||||
@{{ notification.target.screen_name }}
|
@{{ notification.target.redux.acct }}
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<status-content
|
<status-content
|
||||||
class="faint"
|
class="faint"
|
||||||
:status="notification.action"
|
:status="notification.status"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -188,6 +188,8 @@ export const parseUser = (data) => {
|
||||||
output.rights = output.rights || {}
|
output.rights = output.rights || {}
|
||||||
output.notification_settings = output.notification_settings || {}
|
output.notification_settings = output.notification_settings || {}
|
||||||
|
|
||||||
|
output.redux = data
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +360,11 @@ export const parseNotification = (data) => {
|
||||||
output.created_at = new Date(data.created_at)
|
output.created_at = new Date(data.created_at)
|
||||||
output.id = parseInt(data.id)
|
output.id = parseInt(data.id)
|
||||||
|
|
||||||
|
output.redux = data
|
||||||
|
output.redux.account = parseUser(data.account)
|
||||||
|
output.redux.status = isStatusNotification(output.type) ? parseStatus(data.status) : null
|
||||||
|
output.redux.target = output.type !== 'move' ? null : parseUser(data.target)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue