aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases/MarkUseCase.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/usecases/MarkUseCase.ts')
-rw-r--r--src/background/usecases/MarkUseCase.ts17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/background/usecases/MarkUseCase.ts b/src/background/usecases/MarkUseCase.ts
index 8b544aa..e376c55 100644
--- a/src/background/usecases/MarkUseCase.ts
+++ b/src/background/usecases/MarkUseCase.ts
@@ -21,7 +21,7 @@ export default class MarkUseCase {
async setGlobal(key: string, x: number, y: number): Promise<any> {
let tab = await this.tabPresenter.getCurrent();
- let mark = { tabId: tab.id, url: tab.url, x, y };
+ let mark = { tabId: tab.id as number, url: tab.url as string, x, y };
return this.markRepository.setMark(key, mark);
}
@@ -33,15 +33,14 @@ export default class MarkUseCase {
return this.consoleClient.showError(
current.id as number, 'Mark is not set');
}
-
- return this.contentMessageClient.scrollTo(
- mark.tabId, mark.x, mark.y
- ).then(() => {
+ try {
+ await this.contentMessageClient.scrollTo(mark.tabId, mark.x, mark.y);
return this.tabPresenter.select(mark.tabId);
- }).catch(async() => {
+ } catch (e) {
let tab = await this.tabPresenter.create(mark.url);
- let mark2 = { tabId: tab.id, url: mark.url, x: mark.x, y: mark.y };
- return this.markRepository.setMark(key, mark2);
- });
+ return this.markRepository.setMark(key, {
+ tabId: tab.id as number, url: mark.url, x: mark.x, y: mark.y,
+ });
+ }
}
}