aboutsummaryrefslogtreecommitdiff
path: root/src/background/usecases
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-06 22:17:01 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-06 22:17:18 +0900
commitb002d70070a1b691b635220bc694c48df36faca5 (patch)
treefd69cc7a74e30c33f33376acf7e36ce585c819d9 /src/background/usecases
parenta0882bbceb7ed71d56bf8557620449fbc3f19749 (diff)
src/content
Diffstat (limited to 'src/background/usecases')
-rw-r--r--src/background/usecases/MarkUseCase.ts17
-rw-r--r--src/background/usecases/VersionUseCase.ts2
-rw-r--r--src/background/usecases/filters.ts6
3 files changed, 13 insertions, 12 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,
+ });
+ }
}
}
diff --git a/src/background/usecases/VersionUseCase.ts b/src/background/usecases/VersionUseCase.ts
index 3a3cc2e..8154eba 100644
--- a/src/background/usecases/VersionUseCase.ts
+++ b/src/background/usecases/VersionUseCase.ts
@@ -1,4 +1,3 @@
-import manifest from '../../../manifest.json';
import TabPresenter from '../presenters/TabPresenter';
import NotifyPresenter from '../presenters/NotifyPresenter';
@@ -13,6 +12,7 @@ export default class VersionUseCase {
}
notify(): Promise<void> {
+ let manifest = browser.runtime.getManifest();
let title = `Vim Vixen ${manifest.version} has been installed`;
let message = 'Click here to see release notes';
let url = this.releaseNoteUrl(manifest.version);
diff --git a/src/background/usecases/filters.ts b/src/background/usecases/filters.ts
index 44eb56f..84a42fb 100644
--- a/src/background/usecases/filters.ts
+++ b/src/background/usecases/filters.ts
@@ -40,7 +40,8 @@ const filterByPathname = (items: Item[], min: number): Item[] => {
let pathname = url.origin + url.pathname;
if (!hash[pathname]) {
hash[pathname] = item;
- } else if (hash[pathname].url.length > item.url.length) {
+ } else if ((hash[pathname].url as string).length >
+ (item.url as string).length) {
hash[pathname] = item;
}
}
@@ -57,7 +58,8 @@ const filterByOrigin = (items: Item[], min: number): Item[] => {
let origin = new URL(item.url as string).origin;
if (!hash[origin]) {
hash[origin] = item;
- } else if (hash[origin].url.length > item.url.length) {
+ } else if ((hash[origin].url as string).length >
+ (item.url as string).length) {
hash[origin] = item;
}
}