refs #2287 Rewrite poll notification to poll vote event

This commit is contained in:
AkiraFukushima 2021-03-24 00:46:31 +09:00
parent abbf69d09e
commit 5345f2947a
14 changed files with 42 additions and 28 deletions

View File

@ -191,7 +191,7 @@
"emoji-mart-vue": "^2.6.6",
"i18next": "^19.9.2",
"lodash": "^4.17.21",
"megalodon": "3.5.2",
"megalodon": "3.6.0",
"minimist": "^1.2.5",
"moment": "^2.29.1",
"mousetrap": "^1.6.5",

View File

@ -16,7 +16,7 @@ const state = (): NotificationState => {
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
}
}
}
@ -66,7 +66,7 @@ describe('Preferences/Notification', () => {
follow_request: false,
reaction: false,
status: false,
poll: false
poll_vote: false
}
}
}
@ -85,7 +85,7 @@ describe('Preferences/Notification', () => {
follow_request: false,
reaction: false,
status: false,
poll: false
poll_vote: false
}
})
})
@ -115,7 +115,7 @@ describe('Preferences/Notification', () => {
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
}
})
expect(App.actions.loadPreferences).toBeCalled()

View File

@ -13,7 +13,7 @@ describe('Preferences/Notification', () => {
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
}
}
}
@ -28,7 +28,8 @@ describe('Preferences/Notification', () => {
follow: false,
follow_request: false,
reaction: false,
status: false
status: false,
poll_vote: false
}
})
expect(state.notification.notify).toEqual({
@ -38,7 +39,8 @@ describe('Preferences/Notification', () => {
follow: false,
follow_request: false,
reaction: false,
status: false
status: false,
poll_vote: false
})
})
})

View File

@ -197,7 +197,7 @@
"reaction": "Notify me when I receive a emoji reaction",
"follow_request": "Notify me when I receive a follow request",
"status": "Notify me when I receive a status notification",
"poll": "Notify me when I receive a vote of poll"
"poll_vote": "Notify me when I receive a vote of poll"
}
},
"account": {

View File

@ -1439,8 +1439,8 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
} as NotificationConstructorOptions
}
break
case NotificationType.Poll:
if (notifyConfig.poll) {
case NotificationType.PollVote:
if (notifyConfig.poll_vote) {
return {
title: i18next.t('notification.poll_vote.title'),
body: i18next.t('notification.poll_vote.body', { username: username(notification.account) }),

View File

@ -50,7 +50,7 @@ const notify: Notify = {
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
}
const language: LanguageSet = {

View File

@ -24,8 +24,8 @@
<el-form-item for="notifyStatus" :label="$t('preferences.notification.enable.status')">
<el-switch v-model="notifyStatus" active-color="#13ce66"> </el-switch>
</el-form-item>
<el-form-item from="notifyPoll" :label="$t('preferences.notification.enable.poll')">
<el-switch v-model="notifyPoll" active-color="#13ce66"> </el-switch>
<el-form-item from="notifyPollVote" :label="$t('preferences.notification.enable.poll_vote')">
<el-switch v-model="notifyPollVote" active-color="#13ce66"> </el-switch>
</el-form-item>
</el-form>
</div>
@ -105,13 +105,13 @@ export default {
})
}
},
notifyPoll: {
notifyPollVote: {
get() {
return this.$store.state.Preferences.Notification.notification.notify.poll
return this.$store.state.Preferences.Notification.notification.notify.poll_vote
},
set(value) {
this.$store.dispatch('Preferences/Notification/updateNotify', {
poll: value
poll_vote: value
})
}
}

View File

@ -97,7 +97,7 @@
>
</status>
<PollVote
v-else-if="message.type === 'poll'"
v-else-if="message.type === 'poll_vote'"
:message="message"
:filter="filter"
:focused="focused"

View File

@ -41,7 +41,7 @@ const state = (): AppState => ({
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
},
tootPadding: 8,
timeFormat: TimeFormat.Absolute.value,

View File

@ -20,7 +20,7 @@ const state: NotificationState = {
follow_request: true,
reaction: true,
status: true,
poll: true
poll_vote: true
}
}
}

View File

@ -106,7 +106,13 @@ const actions: ActionTree<MentionsState, RootState> = {
)
const res = await client.getNotifications({
limit: 30,
exclude_types: [NotificationType.Follow, NotificationType.Favourite, NotificationType.Reblog, NotificationType.Poll]
exclude_types: [
NotificationType.Follow,
NotificationType.Favourite,
NotificationType.Reblog,
NotificationType.PollVote,
NotificationType.PollExpired
]
})
commit(MUTATION_TYPES.UPDATE_MENTIONS, res.data)
return res.data
@ -126,7 +132,13 @@ const actions: ActionTree<MentionsState, RootState> = {
.getNotifications({
max_id: lastMention.id,
limit: 30,
exclude_types: [NotificationType.Follow, NotificationType.Favourite, NotificationType.Reblog, NotificationType.Poll]
exclude_types: [
NotificationType.Follow,
NotificationType.Favourite,
NotificationType.Reblog,
NotificationType.PollVote,
NotificationType.PollExpired
]
})
.then(res => {
commit(MUTATION_TYPES.INSERT_MENTIONS, res.data)

View File

@ -155,7 +155,7 @@ const getters: GetterTree<NotificationsState, RootState> = {
case NotificationType.EmojiReaction:
case NotificationType.FollowRequest:
case NotificationType.Status:
case NotificationType.Poll:
case NotificationType.PollVote:
return true
default:
return false

View File

@ -6,5 +6,5 @@ export type Notify = {
follow_request: boolean
reaction: boolean
status: boolean
poll: boolean
poll_vote: boolean
}

View File

@ -8840,10 +8840,10 @@ media-typer@0.3.0:
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
megalodon@3.5.2:
version "3.5.2"
resolved "https://registry.yarnpkg.com/megalodon/-/megalodon-3.5.2.tgz#9f3e3e42ba620bd0321de1d5255af3aece3f35d7"
integrity sha512-HuEeFa4HRGrgeZVsINz8qPOlZ130EgvJ0rXcOYS3Vn7XIv3LML50GsIUWHQbeaCEVDw/Vg3NOpXFBp/Lh+b6VQ==
megalodon@3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/megalodon/-/megalodon-3.6.0.tgz#924c497dc33f8be40032170c8d3fec286c7e78a0"
integrity sha512-iL0M2uro2Pmn6THHkpPis6QqiydTWAG3LijGQcNk2jaUIi96DnhERuHXAyZjleZdGHn3My/fgpUnY2fysx+YbA==
dependencies:
"@types/oauth" "^0.9.0"
"@types/ws" "^7.2.0"