From 09e3bfce628bf918280f2241d806957b36799fbe Mon Sep 17 00:00:00 2001 From: kPherox Date: Sun, 19 May 2019 23:01:33 +0900 Subject: [PATCH] Add `get-timeline` channel to ipcMain --- src/main/Timeline.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/Timeline.ts b/src/main/Timeline.ts index 8c11fa85..9c8c2345 100644 --- a/src/main/Timeline.ts +++ b/src/main/Timeline.ts @@ -27,6 +27,7 @@ export default class Timeline { public static ready() { ipcMain.on('add-timeline', (event: Event, name: string, type: string) => this.onAddTimeline(event, name, type)) + ipcMain.on('get-timeline', (event: Event, id: string) => event.returnValue = this.getTimeline(id)) ipcMain.on('no-auth-timeline', (event: Event, name: string) => this.onNoAuthTimeline(event, name)) @@ -59,6 +60,19 @@ export default class Timeline { } } + private static async getTimeline(id: string): Promise { + let db = Datastore.create({ + filename: join(app.getPath("userData"), "timeline.db"), + autoload: true + }) + + try { + return db.findOne({ _id: id }) + } catch (err) { + throw err + } + } + private static async onNoAuthTimeline(event: Event, name: string) { try { const client = Client.getNoAuthClient(name)