Change renderer add-timeline
value to nedb id
This commit is contained in:
parent
c0b89e99b0
commit
28fb6ffda6
|
@ -14,19 +14,13 @@ import { Component, Prop, Vue } from 'vue-property-decorator'
|
|||
|
||||
import Column from '@/components/Timeline/Column.vue'
|
||||
|
||||
interface TimelineDoc {
|
||||
_id: string
|
||||
name: string
|
||||
type: string
|
||||
}
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
Column,
|
||||
}
|
||||
})
|
||||
export default class Main extends Vue {
|
||||
@Prop() public initTimeline?: TimelineDoc
|
||||
@Prop() public initTimelineId?: string
|
||||
|
||||
public timelines: string[] = []
|
||||
|
||||
|
@ -36,21 +30,21 @@ export default class Main extends Vue {
|
|||
}
|
||||
|
||||
created() {
|
||||
if (this.initTimeline === undefined) {
|
||||
if (this.initTimelineId === undefined) {
|
||||
// LocalStorage から this.timelines に順番を入れる
|
||||
return
|
||||
}
|
||||
|
||||
this.timelines.push(this.initTimeline._id)
|
||||
this.timelines.push(this.initTimelineId)
|
||||
}
|
||||
|
||||
mounted() {
|
||||
ipcRenderer.on('add-timeline', (_e: Event, tl?: TimelineDoc, error?: Error) => {
|
||||
if (error != undefined || tl === undefined) {
|
||||
ipcRenderer.on('add-timeline', (_e: Event, id?: string, error?: Error) => {
|
||||
if (error != undefined || id === undefined) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
this.timelines.push(tl._id)
|
||||
this.timelines.push(id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class Timeline {
|
|||
|
||||
try {
|
||||
let newDoc = await db.insert(docs)
|
||||
event.sender.send(`add-timeline`, newDoc)
|
||||
event.sender.send(`add-timeline`, newDoc._id)
|
||||
} catch (err) {
|
||||
let error = new Error("Cannot save timeline.")
|
||||
error.name = "ERROR_ADD_TIMELINE"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<template>
|
||||
<div id="app" :style="styles">
|
||||
<Welcome v-if="isStartup"/>
|
||||
<Main :init-timeline="initTimeline" v-else/>
|
||||
<Main :init-timeline-id="initTimelineId" v-else/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -12,12 +12,6 @@ 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,
|
||||
|
@ -28,7 +22,7 @@ export default class App extends Vue {
|
|||
public isDarkMode: boolean = false
|
||||
public isStartup: boolean = true
|
||||
public fontSize: string = '16px'
|
||||
public initTimeline?: TimelineDoc
|
||||
public initTimelineId?: string
|
||||
|
||||
public get styles(): { [key: string]: string } {
|
||||
return {
|
||||
|
@ -49,12 +43,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?: TimelineDoc, error?: Error) => {
|
||||
if (error != undefined || tl === undefined) {
|
||||
ipcRenderer.once('add-timeline', (_e: Event, id?: string, error?: Error) => {
|
||||
if (error != undefined) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
this.initTimeline = tl
|
||||
this.initTimelineId = id
|
||||
this.isStartup = false
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user