diff --git a/src/components/AddColumn/PublicTimeline.vue b/src/components/AddColumn/PublicTimeline.vue index 91c6dc9c..67607ddd 100644 --- a/src/components/AddColumn/PublicTimeline.vue +++ b/src/components/AddColumn/PublicTimeline.vue @@ -14,7 +14,7 @@
{{value.name}} -
{{status.id}}
+
{{status.id}}
} type UpdateListener = (e: Event, status: Status) => void type Timelines = Timeline[] @@ -59,28 +59,28 @@ export default class AddColumn extends Vue { this.showInput = false let instance = this.instance - this.pubTL.push({ name: instance, statuses: [] }) - this.timeline() + let timeline: Timeline = { name: this.instance, statuses: new Map() } + + this.pubTL.push(timeline) + this.loadTL(timeline) let updateListener = (_: Event, status: Status) => { - this.pubTL.filter(tl => tl.name === instance).forEach(function (tl) { - tl.statuses.unshift(status) + this.pubTL.filter(tl => tl.name === timeline.name).forEach(function (tl) { + tl.statuses.set(status.id, status) }) this.$forceUpdate() } - ipcRenderer.on(`update-${instance}-no-auth`, updateListener) - this.updateListeners.push([`update-${instance}-no-auth`, updateListener]) + ipcRenderer.on(`update-${timeline.name}-no-auth`, updateListener) + this.updateListeners.push([`update-${timeline.name}-no-auth`, updateListener]) ipcRenderer.send('open-streaming', instance, 'no-auth') } - public timeline() { - this.pubTL.forEach(function (tl) { - ipcRenderer.on(`timeline-${tl.name}-no-auth`, (_: Event, statuses: Status[]) => { - tl.statuses = statuses - }) - ipcRenderer.send('no-auth-timeline', tl.name) + public loadTL(timeline: Timeline) { + ipcRenderer.once(`timeline-${timeline.name}-no-auth`, (_: Event, statuses: Status[]) => { + timeline.statuses = new Map(statuses.map((status): [number, Status] => [status.id, status])) }) + ipcRenderer.send('no-auth-timeline', timeline.name) } } =