Change renderer add-timeline value to nedb id

This commit is contained in:
kPherox 2019-05-22 16:42:03 +09:00
parent c0b89e99b0
commit 28fb6ffda6
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
3 changed files with 12 additions and 24 deletions

View File

@ -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)
})
}
}

View File

@ -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"

View File

@ -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
})
}