diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-04-30 14:00:07 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 11:14:19 +0900 |
commit | c60d0e7392fc708e961614d6b756a045de74f458 (patch) | |
tree | 0b9a5fce1879e38a92d5dbb2915779aee0ad22d6 /src/background/repositories/MarkRepository.ts | |
parent | 257162e5b6b4993e1dff0d705ffa6f0d809033eb (diff) |
Rename .js/.jsx to .ts/.tsx
Diffstat (limited to 'src/background/repositories/MarkRepository.ts')
-rw-r--r-- | src/background/repositories/MarkRepository.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/background/repositories/MarkRepository.ts b/src/background/repositories/MarkRepository.ts new file mode 100644 index 0000000..282c712 --- /dev/null +++ b/src/background/repositories/MarkRepository.ts @@ -0,0 +1,33 @@ +import MemoryStorage from '../infrastructures/MemoryStorage'; +import GlobalMark from '../domains/GlobalMark'; + +const MARK_KEY = 'mark'; + +export default class MarkRepository { + constructor() { + this.cache = new MemoryStorage(); + } + + getMark(key) { + let marks = this.getOrEmptyMarks(); + let data = marks[key]; + if (!data) { + return Promise.resolve(undefined); + } + let mark = new GlobalMark(data.tabId, data.url, data.x, data.y); + return Promise.resolve(mark); + } + + setMark(key, mark) { + let marks = this.getOrEmptyMarks(); + marks[key] = { tabId: mark.tabId, url: mark.url, x: mark.x, y: mark.y }; + this.cache.set(MARK_KEY, marks); + + return Promise.resolve(); + } + + getOrEmptyMarks() { + return this.cache.get(MARK_KEY) || {}; + } +} + |