Add listener for add-timeline
to Main component
This commit is contained in:
parent
8221f5495f
commit
7359995a3e
|
@ -9,6 +9,7 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator'
|
||||
|
||||
import Column from '@/components/Timeline/Column.vue'
|
||||
|
@ -31,6 +32,7 @@ export default class Main extends Vue {
|
|||
|
||||
beforeDestroy() {
|
||||
// this.timelines を LocalStorage とかに保持させる
|
||||
ipcRenderer.removeAllListeners('add-timeline')
|
||||
}
|
||||
|
||||
created() {
|
||||
|
@ -41,6 +43,16 @@ export default class Main extends Vue {
|
|||
|
||||
this.timelines.push(this.initTimeline._id)
|
||||
}
|
||||
|
||||
mounted() {
|
||||
ipcRenderer.on('add-timeline', (_e: Event, tl?: TimelineDoc, error?: Error) => {
|
||||
if (error != undefined || tl === undefined) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
this.timelines.push(tl._id)
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -54,8 +54,8 @@ export default class Timeline {
|
|||
let newDoc = await db.insert(docs)
|
||||
event.sender.send(`add-timeline`, newDoc)
|
||||
} catch (err) {
|
||||
let error = new Error("You cannot login already logined account.")
|
||||
error.name = "ERROR_YOU_TRY_ANOTHER_ACCOUNT"
|
||||
let error = new Error("Cannot save timeline.")
|
||||
error.name = "ERROR_ADD_TIMELINE"
|
||||
event.sender.send(`add-timeline`, undefined, error)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user