aboutsummaryrefslogtreecommitdiff
path: root/src/background/repositories/RepeatRepository.ts
blob: 00098d3eadf3e7c0175361530a326d0d35bebf09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { injectable } from "tsyringe";
import { Operation } from "../../shared/operations";
import MemoryStorage from "../infrastructures/MemoryStorage";

const REPEAT_KEY = "repeat";

export default interface RepeatRepository {
  getLastOperation(): Operation | undefined;

  setLastOperation(op: Operation): void;
}

@injectable()
export class RepeatRepositoryImpl implements RepeatRepository {
  private cache: MemoryStorage;

  constructor() {
    this.cache = new MemoryStorage();
  }

  getLastOperation(): Operation | undefined {
    return this.cache.get(REPEAT_KEY);
  }

  setLastOperation(op: Operation): void {
    this.cache.set(REPEAT_KEY, op);
  }
}