1
0
mirror of https://github.com/h3poteto/whalebird-desktop synced 2025-02-10 08:40:39 +01:00

Merge pull request #1394 from h3poteto/iss-1281

refs #1281 Handle emoji reactions in web socket
This commit is contained in:
AkiraFukushima 2020-04-25 21:40:39 +09:00 committed by GitHub
commit f97872db8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 96 additions and 72 deletions

View File

@ -12,7 +12,8 @@ const state = (): NotificationState => {
reply: true,
reblog: true,
favourite: true,
follow: true
follow: true,
reaction: true
}
}
}
@ -58,7 +59,8 @@ describe('Preferences/Notification', () => {
reply: false,
reblog: false,
favourite: false,
follow: false
follow: false,
reaction: false
}
}
})
@ -70,7 +72,8 @@ describe('Preferences/Notification', () => {
reply: false,
reblog: false,
favourite: false,
follow: false
follow: false,
reaction: false
}
})
})
@ -93,7 +96,8 @@ describe('Preferences/Notification', () => {
reply: false,
reblog: false,
favourite: true,
follow: true
follow: true,
reaction: true
}
})
expect(App.actions.loadPreferences).toBeCalled()

View File

@ -9,7 +9,8 @@ describe('Preferences/Notification', () => {
reply: true,
reblog: true,
favourite: true,
follow: true
follow: true,
reaction: true
}
}
}

View File

@ -179,7 +179,8 @@
"reply": "Notify me when I receive a reply",
"reblog": "Notify me when I receive a reblog",
"favourite": "Notify me when I receive a favourite",
"follow": "Notify me when I receive a follow"
"follow": "Notify me when I receive a follow",
"reaction": "Notify me when I receive a emoji reaction"
}
},
"account": {
@ -453,6 +454,10 @@
"reblog": {
"title": "Reblog",
"body": "{{username}} boosted your status"
},
"reaction": {
"title": "Reaction",
"body": "{{username}} reacted your status"
}
}
}

View File

@ -1442,6 +1442,15 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
} as NotificationConstructorOptions
}
break
case 'emoji_reaction':
if (notifyConfig.reaction) {
return {
title: i18next.t('notification.reaction.title'),
body: i18next.t('notification.reaction.body', { username: username(notification.account) }),
silent: false
} as NotificationConstructorOptions
}
break
default:
break
}

View File

@ -45,7 +45,8 @@ const notify: Notify = {
reply: true,
reblog: true,
favourite: true,
follow: true
follow: true,
reaction: true
}
const language: LanguageSet = {

View File

@ -1,37 +1,25 @@
<template>
<div id="notification">
<h2>{{ $t('preferences.notification.title') }}</h2>
<el-form class="section" label-position="right" label-width="250px" size="small">
<p class="description">{{ $t('preferences.notification.enable.description') }}</p>
<el-form-item for="notifyReply" :label="$t('preferences.notification.enable.reply')">
<el-switch
id="notifyReply"
v-model="notifyReply"
active-color="#13ce66">
</el-switch>
</el-form-item>
<el-form-item for="notifyReblog" :label="$t('preferences.notification.enable.reblog')">
<el-switch
id="notifyReblog"
v-model="notifyReblog"
active-color="#13ce66">
</el-switch>
</el-form-item>
<el-form-item for="notifyFavourite" :label="$t('preferences.notification.enable.favourite')">
<el-switch
id="notifyFavourite"
v-model="notifyFavourite"
active-color="#13ce66">
</el-switch>
</el-form-item>
<el-form-item for="notifyFollow" :label="$t('preferences.notification.enable.follow')">
<el-switch
v-model="notifyFollow"
active-color="#13ce66">
</el-switch>
</el-form-item>
</el-form>
</div>
<div id="notification">
<h2>{{ $t('preferences.notification.title') }}</h2>
<el-form class="section" label-position="right" label-width="300px" size="small">
<p class="description">{{ $t('preferences.notification.enable.description') }}</p>
<el-form-item for="notifyReply" :label="$t('preferences.notification.enable.reply')">
<el-switch id="notifyReply" v-model="notifyReply" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item for="notifyReblog" :label="$t('preferences.notification.enable.reblog')">
<el-switch id="notifyReblog" v-model="notifyReblog" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item for="notifyReaction" :label="$t('preferences.notification.enable.reaction')">
<el-switch id="notifyReaction" v-model="notifyReaction" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item for="notifyFavourite" :label="$t('preferences.notification.enable.favourite')">
<el-switch id="notifyFavourite" v-model="notifyFavourite" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item for="notifyFollow" :label="$t('preferences.notification.enable.follow')">
<el-switch v-model="notifyFollow" active-color="#13ce66"> </el-switch>
</el-form-item>
</el-form>
</div>
</template>
<script>
@ -39,54 +27,63 @@ export default {
name: 'notification',
computed: {
notifyReply: {
get () {
get() {
return this.$store.state.Preferences.Notification.notification.notify.reply
},
set (value) {
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
reply: value
})
}
},
notifyReblog: {
get () {
get() {
return this.$store.state.Preferences.Notification.notification.notify.reblog
},
set (value) {
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
reblog: value
})
}
},
notifyFavourite: {
get () {
get() {
return this.$store.state.Preferences.Notification.notification.notify.favourite
},
set (value) {
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
favourite: value
})
}
},
notifyFollow: {
get () {
get() {
return this.$store.state.Preferences.Notification.notification.notify.follow
},
set (value) {
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
follow: value
})
}
},
notifyReaction: {
get() {
return this.$store.state.Preferences.Notification.notification.notify.reaction
},
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
reaction: value
})
}
}
},
created () {
this.$store.dispatch('Preferences/Notification/loadNotification')
.catch(() => {
this.$message({
message: this.$t('message.preferences_load_error'),
type: 'error'
})
created() {
this.$store.dispatch('Preferences/Notification/loadNotification').catch(() => {
this.$message({
message: this.$t('message.preferences_load_error'),
type: 'error'
})
})
}
}
</script>

View File

@ -18,7 +18,8 @@
<icon name="star" scale="0.7"></icon>
</div>
<div class="action-detail">
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span> favourited your status
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span
>{{ $t('notification.favourite.body') }}
</div>
<div class="action-icon" role="presentation">
<FailoverImg :src="message.account.avatar" :alt="`Avatar of ${message.account.username}`" />
@ -141,7 +142,7 @@ export default {
timeFormat: state => state.App.timeFormat,
language: state => state.App.language
}),
shortcutEnabled: function() {
shortcutEnabled: function () {
return this.focused && !this.overlaid
}
},
@ -151,13 +152,13 @@ export default {
}
},
watch: {
focused: function(newState, oldState) {
focused: function (newState, oldState) {
if (newState) {
this.$nextTick(function() {
this.$nextTick(function () {
this.$refs.status.focus()
})
} else if (oldState && !newState) {
this.$nextTick(function() {
this.$nextTick(function () {
this.$refs.status.blur()
})
}

View File

@ -14,7 +14,8 @@
<icon name="user-plus" scale="0.7"></icon>
</div>
<div class="action-detail">
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span> is now following you
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span
>{{ $t('notification.follow.body') }}
</div>
<div class="action-icon" role="presentation">
<FailoverImg :src="message.account.avatar" />

View File

@ -18,7 +18,8 @@
{{ message.emoji }}
</div>
<div class="action-detail">
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span> reacted to your status
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span
>{{ $t('notification.reaction.body') }}
</div>
<div class="action-icon" role="presentation">
<FailoverImg :src="message.account.avatar" :alt="`Avatar of ${message.account.username}`" />

View File

@ -18,7 +18,8 @@
<icon name="retweet" scala="0.7"></icon>
</div>
<div class="action-detail">
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span> boosted your status
<span class="bold" @click="openUser(message.account)"><bdi v-html="username(message.account)"></bdi></span
>{{ $t('notification.reblog.body') }}
</div>
<div class="action-icon" role="presentation">
<FailoverImg :src="message.account.avatar" :alt="`Avatar of ${message.account.username}`" />
@ -142,7 +143,7 @@ export default {
timeFormat: state => state.App.timeFormat,
language: state => state.App.language
}),
shortcutEnabled: function() {
shortcutEnabled: function () {
return this.focused && !this.overlaid
}
},
@ -152,13 +153,13 @@ export default {
}
},
watch: {
focused: function(newState, oldState) {
focused: function (newState, oldState) {
if (newState) {
this.$nextTick(function() {
this.$nextTick(function () {
this.$refs.status.focus()
})
} else if (oldState && !newState) {
this.$nextTick(function() {
this.$nextTick(function () {
this.$refs.status.blur()
})
}

View File

@ -39,7 +39,8 @@ const state = (): AppState => ({
reply: true,
reblog: true,
favourite: true,
follow: true
follow: true,
reaction: true
},
tootPadding: 8,
timeFormat: TimeFormat.Absolute.value,

View File

@ -16,7 +16,8 @@ const state: NotificationState = {
reply: true,
reblog: true,
favourite: true,
follow: true
follow: true,
reaction: true
}
}
}

View File

@ -1,6 +1,7 @@
export type Notify = {
reply: boolean,
reblog: boolean,
favourite: boolean,
reply: boolean
reblog: boolean
favourite: boolean
follow: boolean
reaction: boolean
}