diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-10-09 15:08:31 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-10-09 15:08:31 +0900 |
| commit | 136b13e7ca2163f37ee81a8981f0b2205e7303c9 (patch) | |
| tree | 1f92e693afe46ee6ab7327814eaa386edce92b6a /src/client/app/mios.ts | |
| parent | :art: (diff) | |
| download | misskey-136b13e7ca2163f37ee81a8981f0b2205e7303c9.tar.gz misskey-136b13e7ca2163f37ee81a8981f0b2205e7303c9.tar.bz2 misskey-136b13e7ca2163f37ee81a8981f0b2205e7303c9.zip | |
Fix bug and refactor
Diffstat (limited to 'src/client/app/mios.ts')
| -rw-r--r-- | src/client/app/mios.ts | 95 |
1 files changed, 93 insertions, 2 deletions
diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts index 42171e71fa..558c53dcf1 100644 --- a/src/client/app/mios.ts +++ b/src/client/app/mios.ts @@ -212,7 +212,7 @@ export default class MiOS extends EventEmitter { const fetched = () => { this.emit('signedin'); - this.stream = new Stream(this); + this.initStream(); // Finish init callback(); @@ -247,12 +247,103 @@ export default class MiOS extends EventEmitter { // Finish init callback(); - this.stream = new Stream(this); + this.initStream(); } }); } } + @autobind + private initStream() { + this.stream = new Stream(this); + + if (this.store.getters.isSignedIn) { + const main = this.stream.useSharedConnection('main'); + + // 自分の情報が更新されたとき + main.on('meUpdated', i => { + this.store.dispatch('mergeMe', i); + }); + + main.on('readAllNotifications', () => { + this.store.dispatch('mergeMe', { + hasUnreadNotification: false + }); + }); + + main.on('unreadNotification', () => { + this.store.dispatch('mergeMe', { + hasUnreadNotification: true + }); + }); + + main.on('readAllMessagingMessages', () => { + this.store.dispatch('mergeMe', { + hasUnreadMessagingMessage: false + }); + }); + + main.on('unreadMessagingMessage', () => { + this.store.dispatch('mergeMe', { + hasUnreadMessagingMessage: true + }); + }); + + main.on('unreadMention', () => { + this.store.dispatch('mergeMe', { + hasUnreadMentions: true + }); + }); + + main.on('readAllUnreadMentions', () => { + this.store.dispatch('mergeMe', { + hasUnreadMentions: false + }); + }); + + main.on('unreadSpecifiedNote', () => { + this.store.dispatch('mergeMe', { + hasUnreadSpecifiedNotes: true + }); + }); + + main.on('readAllUnreadSpecifiedNotes', () => { + this.store.dispatch('mergeMe', { + hasUnreadSpecifiedNotes: false + }); + }); + + main.on('clientSettingUpdated', x => { + this.store.commit('settings/set', { + key: x.key, + value: x.value + }); + }); + + main.on('homeUpdated', x => { + this.store.commit('settings/setHome', x); + }); + + main.on('mobileHomeUpdated', x => { + this.store.commit('settings/setMobileHome', x); + }); + + main.on('widgetUpdated', x => { + this.store.commit('settings/setWidget', { + id: x.id, + data: x.data + }); + }); + + // トークンが再生成されたとき + // このままではMisskeyが利用できないので強制的にサインアウトさせる + main.on('myTokenRegenerated', () => { + alert('%i18n:common.my-token-regenerated%'); + this.signout(); + }); + } + } + /** * Register service worker */ |