aboutsummaryrefslogtreecommitdiff
path: root/src/content/repositories/FollowMasterRepository.ts
blob: cc49e5f8a0b4e942c6e3a623d950ce52ba4b5c78 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
export default interface FollowMasterRepository {
  setCurrentFollowMode(newTab: boolean, background: boolean): void;

  getTags(): string[];

  getTagsByPrefix(prefix: string): string[];

  addTag(tag: string): void;

  clearTags(): void;

  getCurrentNewTabMode(): boolean;

  getCurrentBackgroundMode(): boolean;
}

const current: {
  newTab: boolean;
  background: boolean;
  tags: string[];
} = {
  newTab: false,
  background: false,
  tags: [],
};

export class FollowMasterRepositoryImpl implements FollowMasterRepository {
  setCurrentFollowMode(newTab: boolean, background: boolean): void {
    current.newTab = newTab;
    current.background = background;
  }

  getTags(): string[] {
    return current.tags;
  }

  getTagsByPrefix(prefix: string): string[] {
    return current.tags.filter((t) => t.startsWith(prefix));
  }

  addTag(tag: string): void {
    current.tags.push(tag);
  }

  clearTags(): void {
    current.tags = [];
  }

  getCurrentNewTabMode(): boolean {
    return current.newTab;
  }

  getCurrentBackgroundMode(): boolean {
    return current.background;
  }
}