Remove timeline area of AddColumn/User component
Fix name fediverse -> federated
This commit is contained in:
parent
78d87633f5
commit
f00b0dd3f1
|
@ -1,14 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
|
||||||
<div>
|
<div>
|
||||||
<form @submit.prevent="addTL">
|
<form @submit.prevent="addTL">
|
||||||
<label
|
<label v-for="(type) in timelineTypes" :key="type" :class="{selected: type === timelineType}">
|
||||||
v-for="(types,name) in userTimelineTypes"
|
<input type="radio" :value="type" v-model="timelineType">
|
||||||
:key="name"
|
{{ timelineTypeNames[type] }}
|
||||||
:class="{selected: name === timelineType}"
|
|
||||||
>
|
|
||||||
<input type="radio" :value="name" v-model="timelineType">
|
|
||||||
{{ types }}
|
|
||||||
</label>
|
</label>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
type="submit"
|
type="submit"
|
||||||
|
@ -17,133 +12,42 @@
|
||||||
>Add Column</BaseButton>
|
>Add Column</BaseButton>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div id="timelines">
|
|
||||||
<div v-for="(value, key, index) in TL" :key="index" class="tl">
|
|
||||||
{{value.name}}/{{value.type}}
|
|
||||||
<TimelineToot
|
|
||||||
v-for="[id,status] in value.statuses"
|
|
||||||
:key="id"
|
|
||||||
:status="status"
|
|
||||||
:pref-static="pref.static"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ipcRenderer } from "electron"
|
import { ipcRenderer } from "electron"
|
||||||
import { Status } from "megalodon"
|
|
||||||
import { Component, Prop, Vue } from "vue-property-decorator"
|
import { Component, Prop, Vue } from "vue-property-decorator"
|
||||||
import TimelineToot from "@/components/Timeline/Toot.vue"
|
|
||||||
type Timeline = {
|
|
||||||
name: string
|
|
||||||
type: string
|
|
||||||
statuses: Map<number, Status>
|
|
||||||
error?: Error
|
|
||||||
}
|
|
||||||
type Timelines = Timeline[]
|
|
||||||
type DeleteListener = (e: Event, id: number) => void
|
|
||||||
type UpdateListener = (e: Event, status: Status) => void
|
|
||||||
|
|
||||||
@Component({
|
type TimelineType = 'home' | 'notify' | 'dm' | 'local' | 'federated' | 'integrated' | 'localPlus'
|
||||||
components: {
|
|
||||||
TimelineToot
|
@Component
|
||||||
}
|
|
||||||
})
|
|
||||||
export default class UserTimeline extends Vue {
|
export default class UserTimeline extends Vue {
|
||||||
@Prop() public username!: string
|
@Prop() public username!: string
|
||||||
public deleteListeners: [string, DeleteListener][] = []
|
|
||||||
public updateListeners: [string, UpdateListener][] = []
|
public timelineTypes: TimelineType[] = [
|
||||||
public timelineType: string = "home"
|
'home',
|
||||||
public userTimelineTypes: { [key: string]: string } = {
|
'notify',
|
||||||
|
'dm',
|
||||||
|
'local',
|
||||||
|
'federated',
|
||||||
|
'integrated',
|
||||||
|
'localPlus'
|
||||||
|
]
|
||||||
|
|
||||||
|
public timelineTypeNames: { [key: string]: string } = {
|
||||||
home: "Home Timeline",
|
home: "Home Timeline",
|
||||||
notify: "Notifications",
|
notify: "Notifications",
|
||||||
dm: "Direct Messages",
|
dm: "Direct Messages",
|
||||||
local: "Local Timeline",
|
local: "Local Timeline",
|
||||||
fediverse: "Fediverse Timeline",
|
federated: "Federated Timeline",
|
||||||
integrated: "Integrated Timeline (Home + Local)",
|
integrated: "Integrated Timeline (Home + Local)",
|
||||||
localPlus: "Integrated Timeline (Local + Boost + Reply)"
|
localPlus: "Integrated Timeline (Local + Boost + Reply)"
|
||||||
}
|
}
|
||||||
public TL: Timelines = []
|
|
||||||
//test
|
|
||||||
public pref = {
|
|
||||||
static: false
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeDestroy() {
|
public timelineType: TimelineType = "home"
|
||||||
this.updateListeners.forEach(([name, listener]) => {
|
|
||||||
ipcRenderer.removeListener(name, listener)
|
|
||||||
})
|
|
||||||
this.deleteListeners.forEach(([name, listener]) => {
|
|
||||||
ipcRenderer.removeListener(name, listener)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
public sortedStatus(statuses: Map<number, Status>): Map<number, Status> {
|
|
||||||
return statuses.sortByValue(
|
|
||||||
(s1, s2): number => {
|
|
||||||
return s1.created_at > s2.created_at ? -1 : 1
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
public addTL() {
|
public addTL() {
|
||||||
let timeline: Timeline = {
|
ipcRenderer.send("add-timeline", this.username, this.timelineType)
|
||||||
name: this.username,
|
|
||||||
type: this.timelineType,
|
|
||||||
statuses: new Map()
|
|
||||||
}
|
|
||||||
this.TL.push(timeline)
|
|
||||||
// 最新のTLを取得
|
|
||||||
ipcRenderer.once(
|
|
||||||
`timeline-${timeline.name}-${timeline.type}`,
|
|
||||||
(e: Event, statuses: Status[], error?: Error) => {
|
|
||||||
timeline.error = error
|
|
||||||
if (error === undefined) {
|
|
||||||
this.loadTL(timeline, statuses)
|
|
||||||
}
|
|
||||||
this.$forceUpdate()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
ipcRenderer.send("timeline", timeline.name, timeline.type)
|
|
||||||
}
|
|
||||||
public loadTL(timeline: Timeline, statuses: Status[]) {
|
|
||||||
timeline.statuses = new Map(
|
|
||||||
statuses.map((status): [number, Status] => [status.id, status])
|
|
||||||
)
|
|
||||||
|
|
||||||
// streamingを開始
|
|
||||||
this.subscribeStreaming(timeline)
|
|
||||||
}
|
|
||||||
|
|
||||||
public async subscribeStreaming(timeline: Timeline) {
|
|
||||||
// updateイベントを購読
|
|
||||||
let updateListener = (_: Event, status: Status) => {
|
|
||||||
timeline.statuses.set(status.id, status)
|
|
||||||
timeline.statuses = this.sortedStatus(timeline.statuses)
|
|
||||||
this.$forceUpdate()
|
|
||||||
}
|
|
||||||
ipcRenderer.on(`update-${timeline.name}-${timeline.type}`, updateListener)
|
|
||||||
this.updateListeners.push([
|
|
||||||
`update-${timeline.name}-${timeline.type}`,
|
|
||||||
updateListener
|
|
||||||
])
|
|
||||||
|
|
||||||
// deleteイベントを購読
|
|
||||||
let deleteListener = (_: Event, id: number) => {
|
|
||||||
timeline.statuses.delete(id)
|
|
||||||
this.$forceUpdate()
|
|
||||||
}
|
|
||||||
ipcRenderer.on(`delete-${timeline.name}-${timeline.type}`, deleteListener)
|
|
||||||
this.deleteListeners.push([
|
|
||||||
`delete-${timeline.name}-${timeline.type}`,
|
|
||||||
deleteListener
|
|
||||||
])
|
|
||||||
|
|
||||||
ipcRenderer.send("open-streaming", timeline.name, timeline.type)
|
|
||||||
}
|
|
||||||
|
|
||||||
public showAccount(id: number) {
|
|
||||||
console.log("Account dialog:" + id)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -166,16 +70,4 @@ label {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#timelines {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
height: 100vh;
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
.tl {
|
|
||||||
height: 100%;
|
|
||||||
flex-grow: 4;
|
|
||||||
overflow-y: scroll;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
|
@ -22,7 +22,7 @@ export default class Timeline {
|
||||||
notify: "/timelines/notifications",
|
notify: "/timelines/notifications",
|
||||||
dm: "/conversations",
|
dm: "/conversations",
|
||||||
local: "/timelines/public?local=true",
|
local: "/timelines/public?local=true",
|
||||||
fediverse: "/timelines/public",
|
federated: "/timelines/public",
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ready() {
|
public static ready() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user