Add get-timeline channel to ipcMain

This commit is contained in:
kPherox 2019-05-19 23:01:33 +09:00
parent 025c1cf19b
commit 09e3bfce62
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D

View File

@ -27,6 +27,7 @@ export default class Timeline {
public static ready() { public static ready() {
ipcMain.on('add-timeline', (event: Event, name: string, type: string) => this.onAddTimeline(event, name, type)) 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)) 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<TimelineDoc> {
let db = Datastore.create({
filename: join(app.getPath("userData"), "timeline.db"),
autoload: true
})
try {
return db.findOne<TimelineDoc>({ _id: id })
} catch (err) {
throw err
}
}
private static async onNoAuthTimeline(event: Event, name: string) { private static async onNoAuthTimeline(event: Event, name: string) {
try { try {
const client = Client.getNoAuthClient(name) const client = Client.getNoAuthClient(name)