aboutsummaryrefslogtreecommitdiff
path: root/src/background/operators/impls/SelectPreviousSelectedTabOperator.ts
blob: 03a778db45f3b0e5070a0b0efeb26efb4ff98ace (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import Operator from "../Operator";
import TabPresenter from "../../presenters/TabPresenter";

export default class SelectPreviousSelectedTabOperator implements Operator {
  constructor(private readonly tabPresenter: TabPresenter) {}

  async run(): Promise<void> {
    const tabId = await this.tabPresenter.getLastSelectedId();
    if (tabId === null || typeof tabId === "undefined") {
      return Promise.resolve();
    }
    return this.tabPresenter.select(tabId);
  }
}