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