aboutsummaryrefslogtreecommitdiff
path: root/src/background/operators/impls/ShowAddBookmarkOperator.ts
blob: a1752ebbe5e96c840a0e4cd9ac9225e6927689a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import Operator from "../Operator";
import TabPresenter from "../../presenters/TabPresenter";
import ConsoleClient from "../../infrastructures/ConsoleClient";

export default class ShowAddBookmarkOperator implements Operator {
  constructor(
    private readonly tabPresenter: TabPresenter,
    private readonly consoleClient: ConsoleClient,
    private readonly alter: boolean
  ) {}

  async run(): Promise<void> {
    const tab = await this.tabPresenter.getCurrent();
    let command = "addookmark ";
    if (this.alter) {
      command += tab.title || "";
    }
    return this.consoleClient.showCommand(tab.id as number, command);
  }
}