summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/script.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2018-10-07 11:06:17 +0900
committerGitHub <noreply@github.com>2018-10-07 11:06:17 +0900
commitd0570d7fe3a3bf3c6b0312dece74bacc04c3534a (patch)
tree698218279a38f9c78b0350e81b8ac77ae52e4a0d /src/client/app/desktop/script.ts
parentFix お知らせが確認中...のままになる(Announcement Fetching...) (... (diff)
downloadmisskey-d0570d7fe3a3bf3c6b0312dece74bacc04c3534a.tar.gz
misskey-d0570d7fe3a3bf3c6b0312dece74bacc04c3534a.tar.bz2
misskey-d0570d7fe3a3bf3c6b0312dece74bacc04c3534a.zip
V10 (#2826)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * Update CHANGELOG.md * wip * Update CHANGELOG.md * wip * wip * wip * wip
Diffstat (limited to 'src/client/app/desktop/script.ts')
-rw-r--r--src/client/app/desktop/script.ts84
1 files changed, 39 insertions, 45 deletions
diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts
index 05aa928fa3..85c81d73a2 100644
--- a/src/client/app/desktop/script.ts
+++ b/src/client/app/desktop/script.ts
@@ -9,7 +9,6 @@ import './style.styl';
import init from '../init';
import fuckAdBlock from '../common/scripts/fuck-ad-block';
-import { HomeStreamManager } from '../common/scripts/streaming/home';
import composeNotification from '../common/scripts/compose-notification';
import chooseDriveFolder from './api/choose-drive-folder';
@@ -37,6 +36,7 @@ import MkTag from './views/pages/tag.vue';
import MkReversi from './views/pages/games/reversi.vue';
import MkShare from './views/pages/share.vue';
import MkFollow from '../common/views/pages/follow.vue';
+import MiOS from '../mios';
/**
* init
@@ -102,62 +102,56 @@ init(async (launch) => {
}
if ((Notification as any).permission == 'granted') {
- registerNotifications(os.stream);
+ registerNotifications(os);
}
}
}, true);
-function registerNotifications(stream: HomeStreamManager) {
+function registerNotifications(os: MiOS) {
+ const stream = os.stream;
+
if (stream == null) return;
- if (stream.hasConnection) {
- attach(stream.borrow());
- }
+ const connection = stream.useSharedConnection('main');
- stream.on('connected', connection => {
- attach(connection);
- });
-
- function attach(connection) {
- connection.on('notification', notification => {
- const _n = composeNotification('notification', notification);
- const n = new Notification(_n.title, {
- body: _n.body,
- icon: _n.icon
- });
- setTimeout(n.close.bind(n), 6000);
+ connection.on('notification', notification => {
+ const _n = composeNotification('notification', notification);
+ const n = new Notification(_n.title, {
+ body: _n.body,
+ icon: _n.icon
});
+ setTimeout(n.close.bind(n), 6000);
+ });
- 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('driveFileCreated', file => {
+ const _n = composeNotification('driveFileCreated', file);
+ const n = new Notification(_n.title, {
+ body: _n.body,
+ icon: _n.icon
});
+ setTimeout(n.close.bind(n), 5000);
+ });
- connection.on('unread_messaging_message', message => {
- const _n = composeNotification('unread_messaging_message', message);
- const n = new Notification(_n.title, {
- body: _n.body,
- icon: _n.icon
- });
- n.onclick = () => {
- n.close();
- /*(riot as any).mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), {
- user: message.user
- });*/
- };
- setTimeout(n.close.bind(n), 7000);
+ connection.on('unreadMessagingMessage', message => {
+ const _n = composeNotification('unreadMessagingMessage', message);
+ const n = new Notification(_n.title, {
+ body: _n.body,
+ icon: _n.icon
});
+ n.onclick = () => {
+ n.close();
+ /*(riot as any).mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), {
+ user: message.user
+ });*/
+ };
+ setTimeout(n.close.bind(n), 7000);
+ });
- connection.on('reversi_invited', matching => {
- const _n = composeNotification('reversi_invited', matching);
- const n = new Notification(_n.title, {
- body: _n.body,
- icon: _n.icon
- });
+ connection.on('reversiInvited', matching => {
+ const _n = composeNotification('reversiInvited', matching);
+ const n = new Notification(_n.title, {
+ body: _n.body,
+ icon: _n.icon
});
- }
+ });
}