summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-06-21 11:35:28 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-06-21 11:35:28 +0900
commit87fc6522fb204e9196e34ce62c0ddccfed0b5e57 (patch)
treee6e89c94899423a5a4eafbea43163ce90b9d44e3 /src/client
parentMerge pull request #1757 from syuilo/greenkeeper/@types/webpack-4.4.2 (diff)
downloadsharkey-87fc6522fb204e9196e34ce62c0ddccfed0b5e57.tar.gz
sharkey-87fc6522fb204e9196e34ce62c0ddccfed0b5e57.tar.bz2
sharkey-87fc6522fb204e9196e34ce62c0ddccfed0b5e57.zip
Improve ServiceWorker notification
Diffstat (limited to 'src/client')
-rw-r--r--src/client/app/common/scripts/compose-notification.ts62
-rw-r--r--src/client/app/desktop/script.ts28
2 files changed, 39 insertions, 51 deletions
diff --git a/src/client/app/common/scripts/compose-notification.ts b/src/client/app/common/scripts/compose-notification.ts
index cc28f75998..2e58649ac2 100644
--- a/src/client/app/common/scripts/compose-notification.ts
+++ b/src/client/app/common/scripts/compose-notification.ts
@@ -20,34 +20,6 @@ export default function(type, data): Notification {
icon: data.url + '?thumbnail&size=64'
};
- case 'mention':
- return {
- title: `${getUserName(data.user)}さんから:`,
- body: getNoteSummary(data),
- icon: data.user.avatarUrl + '?thumbnail&size=64'
- };
-
- case 'reply':
- return {
- title: `${getUserName(data.user)}さんから返信:`,
- body: getNoteSummary(data),
- icon: data.user.avatarUrl + '?thumbnail&size=64'
- };
-
- case 'quote':
- return {
- title: `${getUserName(data.user)}さんが引用:`,
- body: getNoteSummary(data),
- icon: data.user.avatarUrl + '?thumbnail&size=64'
- };
-
- case 'reaction':
- return {
- title: `${getUserName(data.user)}: ${getReactionEmoji(data.reaction)}:`,
- body: getNoteSummary(data.note),
- icon: data.user.avatarUrl + '?thumbnail&size=64'
- };
-
case 'unread_messaging_message':
return {
title: `${getUserName(data.user)}さんからメッセージ:`,
@@ -62,6 +34,40 @@ export default function(type, data): Notification {
icon: data.parent.avatarUrl + '?thumbnail&size=64'
};
+ case 'notification':
+ switch (data.type) {
+ case 'mention':
+ return {
+ title: `${getUserName(data.user)}さんから:`,
+ body: getNoteSummary(data),
+ icon: data.user.avatarUrl + '?thumbnail&size=64'
+ };
+
+ case 'reply':
+ return {
+ title: `${getUserName(data.user)}さんから返信:`,
+ body: getNoteSummary(data),
+ icon: data.user.avatarUrl + '?thumbnail&size=64'
+ };
+
+ case 'quote':
+ return {
+ title: `${getUserName(data.user)}さんが引用:`,
+ body: getNoteSummary(data),
+ icon: data.user.avatarUrl + '?thumbnail&size=64'
+ };
+
+ case 'reaction':
+ return {
+ title: `${getUserName(data.user)}: ${getReactionEmoji(data.reaction)}:`,
+ body: getNoteSummary(data.note),
+ icon: data.user.avatarUrl + '?thumbnail&size=64'
+ };
+
+ default:
+ return null;
+ }
+
default:
return null;
}
diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts
index 201ab0a83d..beb358c7ee 100644
--- a/src/client/app/desktop/script.ts
+++ b/src/client/app/desktop/script.ts
@@ -115,26 +115,8 @@ function registerNotifications(stream: HomeStreamManager) {
});
function attach(connection) {
- connection.on('drive_file_created', file => {
- const _n = composeNotification('drive_file_created', file);
- const n = new Notification(_n.title, {
- body: _n.body,
- icon: _n.icon
- });
- setTimeout(n.close.bind(n), 5000);
- });
-
- connection.on('mention', note => {
- const _n = composeNotification('mention', note);
- const n = new Notification(_n.title, {
- body: _n.body,
- icon: _n.icon
- });
- setTimeout(n.close.bind(n), 6000);
- });
-
- connection.on('reply', note => {
- const _n = composeNotification('reply', note);
+ connection.on('notification', notification => {
+ const _n = composeNotification('notification', notification);
const n = new Notification(_n.title, {
body: _n.body,
icon: _n.icon
@@ -142,13 +124,13 @@ function registerNotifications(stream: HomeStreamManager) {
setTimeout(n.close.bind(n), 6000);
});
- connection.on('quote', note => {
- const _n = composeNotification('quote', note);
+ connection.on('drive_file_created', file => {
+ const _n = composeNotification('drive_file_created', file);
const n = new Notification(_n.title, {
body: _n.body,
icon: _n.icon
});
- setTimeout(n.close.bind(n), 6000);
+ setTimeout(n.close.bind(n), 5000);
});
connection.on('unread_messaging_message', message => {