aboutsummaryrefslogblamecommitdiff
path: root/src/content/repositories/FollowMasterRepository.ts
blob: da2402c4fee5cad84371ed3cc3718a41168acdc6 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14












                                                                   









































                                                                           
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;
  }
}