From 70b877f9f00086fc84cb7e643cfbe5adcd0d0f86 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 21 Mar 2021 21:27:47 +0900
Subject: [PATCH] refs #2204 Create desktop notification when received poll
notification
---
.../store/Preferences/Notification.spec.ts | 3 ++-
.../unit/store/Preferences/Notification.spec.ts | 3 ++-
src/config/locales/en/translation.json | 3 ++-
src/main/index.ts | 9 +++++++++
src/main/preferences.ts | 3 ++-
.../components/Preferences/Notification.vue | 13 +++++++++++++
src/renderer/store/App.ts | 3 ++-
src/renderer/store/Preferences/Notification.ts | 3 ++-
src/types/notify.ts | 1 +
9 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/spec/renderer/integration/store/Preferences/Notification.spec.ts b/spec/renderer/integration/store/Preferences/Notification.spec.ts
index d2498908..203ee6f5 100644
--- a/spec/renderer/integration/store/Preferences/Notification.spec.ts
+++ b/spec/renderer/integration/store/Preferences/Notification.spec.ts
@@ -15,7 +15,8 @@ const state = (): NotificationState => {
follow: true,
follow_request: true,
reaction: true,
- status: true
+ status: true,
+ poll: true
}
}
}
diff --git a/spec/renderer/unit/store/Preferences/Notification.spec.ts b/spec/renderer/unit/store/Preferences/Notification.spec.ts
index 2de80ede..9de079e7 100644
--- a/spec/renderer/unit/store/Preferences/Notification.spec.ts
+++ b/spec/renderer/unit/store/Preferences/Notification.spec.ts
@@ -12,7 +12,8 @@ describe('Preferences/Notification', () => {
follow: true,
follow_request: true,
reaction: true,
- status: true
+ status: true,
+ poll: true
}
}
}
diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json
index 053b8a93..af432c0f 100644
--- a/src/config/locales/en/translation.json
+++ b/src/config/locales/en/translation.json
@@ -196,7 +196,8 @@
"follow": "Notify me when I receive a follow",
"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"
+ "status": "Notify me when I receive a status notification",
+ "poll": "Notify me when I receive a vote of poll"
}
},
"account": {
diff --git a/src/main/index.ts b/src/main/index.ts
index 8e182128..be5f8da1 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1439,6 +1439,15 @@ const createNotification = (notification: Entity.Notification, notifyConfig: Not
} as NotificationConstructorOptions
}
break
+ case NotificationType.Poll:
+ if (notifyConfig.poll) {
+ return {
+ title: i18next.t('notification.poll_vote.title'),
+ body: i18next.t('notification.poll_vote.body', { username: username(notification.account) }),
+ silent: false
+ } as NotificationConstructorOptions
+ }
+ break
default:
break
}
diff --git a/src/main/preferences.ts b/src/main/preferences.ts
index 2a329338..354fc488 100644
--- a/src/main/preferences.ts
+++ b/src/main/preferences.ts
@@ -49,7 +49,8 @@ const notify: Notify = {
follow: true,
follow_request: true,
reaction: true,
- status: true
+ status: true,
+ poll: true
}
const language: LanguageSet = {
diff --git a/src/renderer/components/Preferences/Notification.vue b/src/renderer/components/Preferences/Notification.vue
index aa950391..413eb82d 100644
--- a/src/renderer/components/Preferences/Notification.vue
+++ b/src/renderer/components/Preferences/Notification.vue
@@ -24,6 +24,9 @@
+
+
+
@@ -101,6 +104,16 @@ export default {
status: value
})
}
+ },
+ notifyPoll: {
+ get() {
+ return this.$store.state.Preferences.Notification.notification.notify.poll
+ },
+ set(value) {
+ this.$store.dispatch('Preferences/Notification/updateNotify', {
+ poll: value
+ })
+ }
}
},
created() {
diff --git a/src/renderer/store/App.ts b/src/renderer/store/App.ts
index 306116af..6e6f7b0f 100644
--- a/src/renderer/store/App.ts
+++ b/src/renderer/store/App.ts
@@ -40,7 +40,8 @@ const state = (): AppState => ({
follow: true,
follow_request: true,
reaction: true,
- status: true
+ status: true,
+ poll: true
},
tootPadding: 8,
timeFormat: TimeFormat.Absolute.value,
diff --git a/src/renderer/store/Preferences/Notification.ts b/src/renderer/store/Preferences/Notification.ts
index a5af21d2..fd3ddcf1 100644
--- a/src/renderer/store/Preferences/Notification.ts
+++ b/src/renderer/store/Preferences/Notification.ts
@@ -19,7 +19,8 @@ const state: NotificationState = {
follow: true,
follow_request: true,
reaction: true,
- status: true
+ status: true,
+ poll: true
}
}
}
diff --git a/src/types/notify.ts b/src/types/notify.ts
index 36881f38..455ab828 100644
--- a/src/types/notify.ts
+++ b/src/types/notify.ts
@@ -6,4 +6,5 @@ export type Notify = {
follow_request: boolean
reaction: boolean
status: boolean
+ poll: boolean
}