2019-04-23 04:46:17 +09:00
|
|
|
<template>
|
|
|
|
<div>
|
2019-04-23 23:42:07 +09:00
|
|
|
<div v-if="showInput">
|
2019-04-24 17:04:44 +09:00
|
|
|
<form @submit.prevent="addTL">
|
|
|
|
<input type="text" placeholder="e.g:mstdn.jp" v-model="instance">
|
|
|
|
<BaseButton
|
|
|
|
type="submit"
|
|
|
|
class="primary fill"
|
|
|
|
style="--font-size:.8em;"
|
|
|
|
:disabled="!hasDomain"
|
|
|
|
>Add Column</BaseButton>
|
|
|
|
</form>
|
2019-04-23 23:42:07 +09:00
|
|
|
</div>
|
|
|
|
<div id="timelines">
|
|
|
|
<div v-for="(value, key, index) in pubTL" :key="index" class="tl">
|
2019-04-24 06:07:15 +09:00
|
|
|
{{value.name}}
|
2019-04-24 17:31:18 +09:00
|
|
|
<div v-for="[id,status] in Array.from(value.statuses)" :key="id" class="tl">{{status.id}}</div>
|
2019-04-23 23:42:07 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-04-23 04:46:17 +09:00
|
|
|
<BaseButton
|
2019-04-24 03:40:04 +09:00
|
|
|
v-if="!showInput"
|
|
|
|
@click.native="showInput = true"
|
|
|
|
class="primary fill"
|
|
|
|
style="--font-size:.8em;"
|
|
|
|
>Show Menu</BaseButton>
|
2019-04-23 04:46:17 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { ipcRenderer } from 'electron'
|
|
|
|
import { Component, Vue } from 'vue-property-decorator'
|
2019-04-24 06:07:15 +09:00
|
|
|
import { Status } from 'megalodon'
|
2019-04-23 04:46:17 +09:00
|
|
|
|
2019-04-24 03:40:04 +09:00
|
|
|
type Instance = string
|
2019-04-24 06:07:15 +09:00
|
|
|
type Timeline = {
|
|
|
|
name: string
|
2019-04-24 17:31:18 +09:00
|
|
|
statuses: Map<number, Status>
|
2019-04-24 06:07:15 +09:00
|
|
|
}
|
2019-04-24 17:15:42 +09:00
|
|
|
type UpdateListener = (e: Event, status: Status) => void
|
2019-04-24 06:07:15 +09:00
|
|
|
type Timelines = Timeline[]
|
2019-04-23 04:46:17 +09:00
|
|
|
@Component
|
|
|
|
export default class AddColumn extends Vue {
|
2019-04-23 23:42:07 +09:00
|
|
|
public instance: Instance = ''
|
2019-04-24 17:15:42 +09:00
|
|
|
public showInput: boolean = true
|
|
|
|
public updateListeners: [string, UpdateListener][] = []
|
2019-04-24 03:40:04 +09:00
|
|
|
public pubTL: Timelines = []
|
|
|
|
|
2019-04-24 17:15:42 +09:00
|
|
|
beforeDestroy() {
|
|
|
|
this.updateListeners.forEach(([name, listener]) => {
|
|
|
|
ipcRenderer.removeListener(name, listener)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-04-24 03:40:04 +09:00
|
|
|
public get hasDomain() {
|
|
|
|
return this.instance != ''
|
|
|
|
}
|
2019-04-23 23:42:07 +09:00
|
|
|
|
|
|
|
public addTL() {
|
|
|
|
this.showInput = false
|
2019-04-24 05:30:16 +09:00
|
|
|
let instance = this.instance
|
|
|
|
|
2019-04-24 17:31:18 +09:00
|
|
|
let timeline: Timeline = { name: this.instance, statuses: new Map() }
|
|
|
|
|
|
|
|
this.pubTL.push(timeline)
|
|
|
|
this.loadTL(timeline)
|
2019-04-24 06:15:56 +09:00
|
|
|
|
2019-04-24 17:15:42 +09:00
|
|
|
let updateListener = (_: Event, status: Status) => {
|
2019-04-24 17:31:18 +09:00
|
|
|
this.pubTL.filter(tl => tl.name === timeline.name).forEach(function (tl) {
|
|
|
|
tl.statuses.set(status.id, status)
|
2019-04-24 06:15:56 +09:00
|
|
|
})
|
2019-04-24 17:15:42 +09:00
|
|
|
this.$forceUpdate()
|
|
|
|
}
|
2019-04-24 17:31:18 +09:00
|
|
|
ipcRenderer.on(`update-${timeline.name}-no-auth`, updateListener)
|
|
|
|
this.updateListeners.push([`update-${timeline.name}-no-auth`, updateListener])
|
2019-04-24 17:15:42 +09:00
|
|
|
|
|
|
|
ipcRenderer.send('open-streaming', instance, 'no-auth')
|
2019-04-24 01:07:20 +09:00
|
|
|
}
|
|
|
|
|
2019-04-24 17:31:18 +09:00
|
|
|
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]))
|
2019-04-24 06:15:56 +09:00
|
|
|
})
|
2019-04-24 17:31:18 +09:00
|
|
|
ipcRenderer.send('no-auth-timeline', timeline.name)
|
2019-04-23 23:42:07 +09:00
|
|
|
}
|
2019-04-23 04:46:17 +09:00
|
|
|
}
|
|
|
|
</script>=
|
|
|
|
|
|
|
|
<style scoped lang="postcss">
|
|
|
|
input {
|
|
|
|
color: var(--color);
|
|
|
|
background-color: transparent;
|
|
|
|
font-size: var(--font-size);
|
|
|
|
border: none;
|
|
|
|
border-bottom: 1px solid #9e9e9e;
|
|
|
|
border-radius: 0;
|
|
|
|
line-height: 3em;
|
|
|
|
width: 80%;
|
|
|
|
outline: none;
|
|
|
|
margin: 1em;
|
|
|
|
|
|
|
|
transition-duration: 0.5s;
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
border-color: #26d69a;
|
|
|
|
}
|
|
|
|
}
|
2019-04-24 03:58:06 +09:00
|
|
|
#timelines {
|
|
|
|
display: flex;
|
|
|
|
width: 100%;
|
2019-04-23 23:42:07 +09:00
|
|
|
}
|
2019-04-24 03:58:06 +09:00
|
|
|
.tl {
|
|
|
|
height: 100%;
|
2019-04-23 23:42:07 +09:00
|
|
|
flex-grow: 4;
|
|
|
|
}
|
2019-04-23 04:46:17 +09:00
|
|
|
</style>
|