forked from mirror/misskey
トップページのタイムラインをリアルタイム更新するように
This commit is contained in:
parent
ba64de334a
commit
6abff253ea
@ -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
|
||||
});
|
||||
} : {});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
},
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user