Change to pass timeline doc to main when startup

This commit is contained in:
kPherox 2019-05-11 16:14:02 +09:00
parent b5e8f29fe3
commit a8bfb2920b
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 13 additions and 5 deletions

View File

@ -36,7 +36,7 @@ export default class Timeline {
private static async onAddTimeline(event: Event, name: string, type: string) {
if (!(type in this.endpoints) && type !== 'no-auth') {
event.sender.send(`add-timeline`, {}, new Error("Not supported type"))
event.sender.send(`add-timeline`, undefined, new Error("Not supported type"))
return
}
@ -54,7 +54,7 @@ export default class Timeline {
if (err) {
let error = new Error("You cannot login already logined account.")
error.name = "ERROR_YOU_TRY_ANOTHER_ACCOUNT"
event.sender.send(`add-timeline`, {}, error)
event.sender.send(`add-timeline`, undefined, error)
} else {
event.sender.send(`add-timeline`, newDocs)
}

View File

@ -1,7 +1,7 @@
<template>
<div id="app" :style="styles">
<Welcome v-if="isStartup"/>
<Main v-else/>
<Main :init-timeline="initTimeline" v-else/>
</div>
</template>
@ -12,6 +12,12 @@ import { Component, Vue } from 'vue-property-decorator'
import Main from '@/components/Main.vue'
import Welcome from '@/components/Welcome.vue'
interface TimelineDoc {
_id: string
name: string
type: string
}
@Component({
components: {
Main,
@ -22,6 +28,7 @@ export default class App extends Vue {
public isDarkMode: boolean = false
public isStartup: boolean = true
public fontSize: string = '16px'
public initTimeline?: TimelineDoc
public get styles(): { [key: string]: string } {
return {
@ -40,11 +47,12 @@ export default class App extends Vue {
ipcRenderer.on('change-color-theme', () => this.isDarkMode = ipcRenderer.sendSync('dark-theme'))
// TODO: TL
if (this.isStartup) {
ipcRenderer.once('add-timeline', (_e: Event, _tl: Object, error?: Error) => {
if (error) {
ipcRenderer.once('add-timeline', (_e: Event, tl?: TimelineDoc, error?: Error) => {
if (error === undefined || tl === undefined) {
console.error(error)
return
}
this.initTimeline = tl
this.isStartup = false
})
}