From 6abff253ea718acc73ba3d1feca53161923319ae Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 4 Sep 2018 12:59:34 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=88=E3=83=83=E3=83=97=E3=83=9A=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=A0=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=82=92=E3=83=AA=E3=82=A2=E3=83=AB=E3=82=BF=E3=82=A4?= =?UTF-8?q?=E3=83=A0=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scripts/streaming/local-timeline.ts | 4 +-- .../views/components/welcome-timeline.vue | 30 ++++++++++++++++--- src/client/app/mios.ts | 6 ++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/client/app/common/scripts/streaming/local-timeline.ts b/src/client/app/common/scripts/streaming/local-timeline.ts index 2834262bd..41c36aa14 100644 --- a/src/client/app/common/scripts/streaming/local-timeline.ts +++ b/src/client/app/common/scripts/streaming/local-timeline.ts @@ -7,9 +7,9 @@ import MiOS from '../../../mios'; */ export class LocalTimelineStream extends Stream { constructor(os: MiOS, me) { - super(os, 'local-timeline', { + super(os, 'local-timeline', me ? { i: me.token - }); + } : {}); } } diff --git a/src/client/app/common/views/components/welcome-timeline.vue b/src/client/app/common/views/components/welcome-timeline.vue index 5a8b9df47..d4e7902c7 100644 --- a/src/client/app/common/views/components/welcome-timeline.vue +++ b/src/client/app/common/views/components/welcome-timeline.vue @@ -31,15 +31,30 @@ export default Vue.extend({ default: undefined } }, + data() { return { fetching: true, - notes: [] + notes: [], + connection: null, + connectionId: null }; }, + mounted() { this.fetch(); + + this.connection = (this as any).os.streams.localTimelineStream.getConnection(); + this.connectionId = (this as any).os.streams.localTimelineStream.use(); + + this.connection.on('note', this.onNote); }, + + beforeDestroy() { + this.connection.off('note', this.onNote); + (this as any).os.streams.localTimelineStream.dispose(this.connectionId); + }, + methods: { fetch(cb?) { this.fetching = true; @@ -49,13 +64,20 @@ export default Vue.extend({ reply: false, renote: false, media: false, - poll: false, - bot: false + poll: false }).then(notes => { this.notes = notes; this.fetching = false; }); - } + }, + + onNote(note) { + if (note.replyId != null) return; + if (note.renoteId != null) return; + if (note.poll != null) return; + + this.notes.unshift(note); + }, } }); diff --git a/src/client/app/mios.ts b/src/client/app/mios.ts index 664848b5e..c2ec7f175 100644 --- a/src/client/app/mios.ts +++ b/src/client/app/mios.ts @@ -3,7 +3,7 @@ import { EventEmitter } from 'eventemitter3'; import * as uuid from 'uuid'; import initStore from './store'; -import { apiUrl, swPublickey, version, lang, googleMapsApiKey } from './config'; +import { apiUrl, version, lang } from './config'; import Progress from './common/scripts/loading'; import Connection from './common/scripts/streaming/stream'; import { HomeStreamManager } from './common/scripts/streaming/home'; @@ -230,13 +230,13 @@ export default class MiOS extends EventEmitter { //#region Init stream managers this.streams.serverStatsStream = new ServerStatsStreamManager(this); this.streams.notesStatsStream = new NotesStatsStreamManager(this); + this.streams.localTimelineStream = new LocalTimelineStreamManager(this, this.store.state.i); this.once('signedin', () => { // Init home stream manager this.stream = new HomeStreamManager(this, this.store.state.i); // Init other stream manager - this.streams.localTimelineStream = new LocalTimelineStreamManager(this, this.store.state.i); this.streams.hybridTimelineStream = new HybridTimelineStreamManager(this, this.store.state.i); this.streams.globalTimelineStream = new GlobalTimelineStreamManager(this, this.store.state.i); this.streams.driveStream = new DriveStreamManager(this, this.store.state.i); @@ -361,7 +361,7 @@ export default class MiOS extends EventEmitter { // A public key your push server will use to send // messages to client apps via a push server. - applicationServerKey: urlBase64ToUint8Array(swPublickey) + applicationServerKey: urlBase64ToUint8Array(this.meta.data.swPublickey) }; // Subscribe push notification