forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
26 lines (20 loc) · 806 Bytes
/
index.ts
File metadata and controls
26 lines (20 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import ClassicTimelineDatabase from './classic'
import IDBTimelineDatabase from './idb'
import type { TimelineCondition, TimelineDatabase } from './types'
class TimelineDatabaseWrapper implements TimelineDatabase {
private classic = new ClassicTimelineDatabase()
private idb = new IDBTimelineDatabase()
batchSave(ticks: timer.timeline.Tick[]): Promise<void> {
return this.idb.batchSave(ticks)
}
select(cond?: TimelineCondition): Promise<timer.timeline.Tick[]> {
return this.idb.select(cond)
}
async migrateFromClassic(): Promise<void> {
const ticks = await this.classic.select()
await this.idb.batchSave(ticks)
await this.classic.clear()
}
}
const timelineDatabase = new TimelineDatabaseWrapper()
export default timelineDatabase