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

View File

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