parent
07897df636
commit
5a7db96feb
7 changed files with 150 additions and 13 deletions
@ -0,0 +1,29 @@ |
|||||||
|
import { injectable } from 'tsyringe'; |
||||||
|
import * as messages from '../../shared/messages'; |
||||||
|
|
||||||
|
@injectable() |
||||||
|
export default class NavigateClient { |
||||||
|
async historyNext(tabId: number): Promise<void> { |
||||||
|
await browser.tabs.sendMessage(tabId, { |
||||||
|
type: messages.NAVIGATE_HISTORY_NEXT, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
async historyPrev(tabId: number): Promise<void> { |
||||||
|
await browser.tabs.sendMessage(tabId, { |
||||||
|
type: messages.NAVIGATE_HISTORY_PREV, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
async linkNext(tabId: number): Promise<void> { |
||||||
|
await browser.tabs.sendMessage(tabId, { |
||||||
|
type: messages.NAVIGATE_LINK_NEXT, |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
async linkPrev(tabId: number): Promise<void> { |
||||||
|
await browser.tabs.sendMessage(tabId, { |
||||||
|
type: messages.NAVIGATE_LINK_PREV, |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
import { injectable } from 'tsyringe'; |
||||||
|
import NavigateClient from '../clients/NavigateClient'; |
||||||
|
import TabPresenter from '../presenters/TabPresenter'; |
||||||
|
|
||||||
|
@injectable() |
||||||
|
export default class NavigateUseCase { |
||||||
|
constructor( |
||||||
|
private tabPresenter: TabPresenter, |
||||||
|
private navigateClient: NavigateClient, |
||||||
|
) { |
||||||
|
} |
||||||
|
|
||||||
|
async openHistoryNext(): Promise<void> { |
||||||
|
let tab = await this.tabPresenter.getCurrent(); |
||||||
|
await this.navigateClient.historyNext(tab.id!!); |
||||||
|
} |
||||||
|
|
||||||
|
async openHistoryPrev(): Promise<void> { |
||||||
|
let tab = await this.tabPresenter.getCurrent(); |
||||||
|
await this.navigateClient.historyPrev(tab.id!!); |
||||||
|
} |
||||||
|
|
||||||
|
async openLinkNext(): Promise<void> { |
||||||
|
let tab = await this.tabPresenter.getCurrent(); |
||||||
|
await this.navigateClient.linkNext(tab.id!!); |
||||||
|
} |
||||||
|
|
||||||
|
async openLinkPrev(): Promise<void> { |
||||||
|
let tab = await this.tabPresenter.getCurrent(); |
||||||
|
await this.navigateClient.linkPrev(tab.id!!); |
||||||
|
} |
||||||
|
|
||||||
|
openParent(): Promise<void> { |
||||||
|
throw new Error('not implemented'); |
||||||
|
} |
||||||
|
|
||||||
|
openRoot(): Promise<void> { |
||||||
|
throw new Error('not implemented'); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
import { injectable } from 'tsyringe'; |
||||||
|
import { Message } from '../../shared/messages'; |
||||||
|
import NavigateUseCase from '../usecases/NavigateUseCase'; |
||||||
|
|
||||||
|
@injectable() |
||||||
|
export default class NavigateController { |
||||||
|
constructor( |
||||||
|
private navigateUseCase: NavigateUseCase, |
||||||
|
) { |
||||||
|
} |
||||||
|
|
||||||
|
openHistoryNext(_m: Message): Promise<void> { |
||||||
|
this.navigateUseCase.openHistoryNext(); |
||||||
|
return Promise.resolve(); |
||||||
|
} |
||||||
|
|
||||||
|
openHistoryPrev(_m: Message): Promise<void> { |
||||||
|
this.navigateUseCase.openHistoryPrev(); |
||||||
|
return Promise.resolve(); |
||||||
|
} |
||||||
|
|
||||||
|
openLinkNext(_m: Message): Promise<void> { |
||||||
|
this.navigateUseCase.openLinkNext(); |
||||||
|
return Promise.resolve(); |
||||||
|
} |
||||||
|
|
||||||
|
openLinkPrev(_m: Message): Promise<void> { |
||||||
|
this.navigateUseCase.openLinkPrev(); |
||||||
|
return Promise.resolve(); |
||||||
|
} |
||||||
|
} |
Reference in new issue