From 003742ec51aa7aea9214442bc0b611e2eb5eaf6e Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Fri, 12 Oct 2018 10:14:33 +0900 Subject: Support global marks which select a tab --- src/background/usecases/mark.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/background/usecases/mark.js (limited to 'src/background/usecases') diff --git a/src/background/usecases/mark.js b/src/background/usecases/mark.js new file mode 100644 index 0000000..2cb3b45 --- /dev/null +++ b/src/background/usecases/mark.js @@ -0,0 +1,29 @@ +import GlobalMark from '../domains/global-mark'; +import TabPresenter from '../presenters/tab'; +import MarkRepository from '../repositories/mark'; +import ConsolePresenter from '../presenters/console'; + +export default class MarkInteractor { + constructor() { + this.tabPresenter = new TabPresenter(); + this.markRepository = new MarkRepository(); + this.consolePresenter = new ConsolePresenter(); + } + + async setGlobal(key, x, y) { + let tab = await this.tabPresenter.getCurrent(); + let mark = new GlobalMark(tab.id, x, y); + return this.markRepository.setMark(key, mark); + } + + async jumpGlobal(key) { + let current = await this.tabPresenter.getCurrent(); + + let mark = await this.markRepository.getMark(key); + if (!mark) { + return this.consolePresenter.showError(current.id, 'Mark is not set'); + } + // TODO scroll pages and handle if tab is gone + return this.tabPresenter.select(mark.tabId); + } +} -- cgit v1.2.3