aboutsummaryrefslogtreecommitdiff
path: root/src/background/operators/impls/RepeatLastOperator.ts
blob: d46daaba6934232756780565f91eeedd2f33ffff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Operator from "../Operator";
import RepeatRepository from "../../repositories/RepeatRepository";
import OperatorFactory from "../OperatorFactory";

export default class RepeatLastOperator implements Operator {
  constructor(
    private readonly repeatRepository: RepeatRepository,
    private readonly operatorFactory: OperatorFactory
  ) {}

  run(): Promise<void> {
    const op = this.repeatRepository.getLastOperation();
    if (typeof op === "undefined") {
      return Promise.resolve();
    }
    return this.operatorFactory.create(op).run();
  }
}