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