aboutsummaryrefslogtreecommitdiff
path: root/src/content/usecases/FollowMasterUseCase.ts
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-04-13 20:37:36 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2020-04-13 20:37:36 +0900
commite1dac618a8b8929f601c7ec8aca3842c5ebf9d03 (patch)
tree6a914a8243c8c02e7752a83667a54d3fa832955c /src/content/usecases/FollowMasterUseCase.ts
parent685f2b7b69218b06b5bb676069e35f79c5048c9b (diff)
Use plugin:prettier/recommended
Diffstat (limited to 'src/content/usecases/FollowMasterUseCase.ts')
-rw-r--r--src/content/usecases/FollowMasterUseCase.ts78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/content/usecases/FollowMasterUseCase.ts b/src/content/usecases/FollowMasterUseCase.ts
index 0e7f394..329f05a 100644
--- a/src/content/usecases/FollowMasterUseCase.ts
+++ b/src/content/usecases/FollowMasterUseCase.ts
@@ -1,10 +1,10 @@
-import { injectable, inject } from 'tsyringe';
-import FollowKeyRepository from '../repositories/FollowKeyRepository';
-import FollowMasterRepository from '../repositories/FollowMasterRepository';
-import FollowSlaveClient from '../client/FollowSlaveClient';
-import FollowSlaveClientFactory from '../client/FollowSlaveClientFactory';
-import SettingRepository from '../repositories/SettingRepository';
-import HintKeyProducer from './HintKeyProducer';
+import { injectable, inject } from "tsyringe";
+import FollowKeyRepository from "../repositories/FollowKeyRepository";
+import FollowMasterRepository from "../repositories/FollowMasterRepository";
+import FollowSlaveClient from "../client/FollowSlaveClient";
+import FollowSlaveClientFactory from "../client/FollowSlaveClientFactory";
+import SettingRepository from "../repositories/SettingRepository";
+import HintKeyProducer from "./HintKeyProducer";
@injectable()
export default class FollowMasterUseCase {
@@ -12,17 +12,17 @@ export default class FollowMasterUseCase {
private producer: HintKeyProducer | null;
constructor(
- @inject('FollowKeyRepository')
+ @inject("FollowKeyRepository")
private followKeyRepository: FollowKeyRepository,
- @inject('FollowMasterRepository')
+ @inject("FollowMasterRepository")
private followMasterRepository: FollowMasterRepository,
- @inject('SettingRepository')
+ @inject("SettingRepository")
private settingRepository: SettingRepository,
- @inject('FollowSlaveClientFactory')
- private followSlaveClientFactory: FollowSlaveClientFactory,
+ @inject("FollowSlaveClientFactory")
+ private followSlaveClientFactory: FollowSlaveClientFactory
) {
this.producer = null;
}
@@ -36,19 +36,21 @@ export default class FollowMasterUseCase {
const viewWidth = window.top.innerWidth;
const viewHeight = window.top.innerHeight;
- this.followSlaveClientFactory.create(window.top).requestHintCount(
- { width: viewWidth, height: viewHeight },
- { x: 0, y: 0 },
- );
+ this.followSlaveClientFactory
+ .create(window.top)
+ .requestHintCount(
+ { width: viewWidth, height: viewHeight },
+ { x: 0, y: 0 }
+ );
- const frameElements = window.document.querySelectorAll('iframe');
+ const frameElements = window.document.querySelectorAll("iframe");
for (let i = 0; i < frameElements.length; ++i) {
const ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement;
const { left: frameX, top: frameY } = ele.getBoundingClientRect();
const client = this.followSlaveClientFactory.create(ele.contentWindow!!);
client.requestHintCount(
{ width: viewWidth, height: viewHeight },
- { x: frameX, y: frameY },
+ { x: frameX, y: frameY }
);
}
}
@@ -67,8 +69,10 @@ export default class FollowMasterUseCase {
const viewHeight = window.innerHeight || doc.documentElement.clientHeight;
let pos = { x: 0, y: 0 };
if (sender !== window) {
- const frameElements = window.document.querySelectorAll('iframe');
- const ele = Array.from(frameElements).find(e => e.contentWindow === sender);
+ const frameElements = window.document.querySelectorAll("iframe");
+ const ele = Array.from(frameElements).find(
+ (e) => e.contentWindow === sender
+ );
if (!ele) {
// elements of the sender is gone
return;
@@ -77,11 +81,7 @@ export default class FollowMasterUseCase {
pos = { x: frameX, y: frameY };
}
const client = this.followSlaveClientFactory.create(sender);
- client.createHints(
- { width: viewWidth, height: viewHeight },
- pos,
- produced,
- );
+ client.createHints({ width: viewWidth, height: viewHeight }, pos, produced);
}
cancelFollow(): void {
@@ -110,17 +110,17 @@ export default class FollowMasterUseCase {
enqueue(key: string): void {
switch (key) {
- case 'Enter':
- this.activate(this.getCurrentTag());
- return;
- case 'Esc':
- this.cancelFollow();
- return;
- case 'Backspace':
- case 'Delete':
- this.followKeyRepository.popKey();
- this.filter(this.getCurrentTag());
- return;
+ case "Enter":
+ this.activate(this.getCurrentTag());
+ return;
+ case "Esc":
+ this.cancelFollow();
+ return;
+ case "Backspace":
+ case "Delete":
+ this.followKeyRepository.popKey();
+ this.filter(this.getCurrentTag());
+ return;
}
this.followKeyRepository.pushKey(key);
@@ -138,13 +138,15 @@ export default class FollowMasterUseCase {
private broadcastToSlaves(handler: (client: FollowSlaveClient) => void) {
const allFrames = [window.self].concat(Array.from(window.frames as any));
- const clients = allFrames.map(w => this.followSlaveClientFactory.create(w));
+ const clients = allFrames.map((w) =>
+ this.followSlaveClientFactory.create(w)
+ );
for (const client of clients) {
handler(client);
}
}
private getCurrentTag(): string {
- return this.followKeyRepository.getKeys().join('');
+ return this.followKeyRepository.getKeys().join("");
}
}