aboutsummaryrefslogtreecommitdiff
path: root/src/content/repositories
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/repositories')
-rw-r--r--src/content/repositories/FollowKeyRepository.ts35
-rw-r--r--src/content/repositories/FollowMasterRepository.ts59
-rw-r--r--src/content/repositories/FollowSlaveRepository.ts31
3 files changed, 125 insertions, 0 deletions
diff --git a/src/content/repositories/FollowKeyRepository.ts b/src/content/repositories/FollowKeyRepository.ts
new file mode 100644
index 0000000..a671b5c
--- /dev/null
+++ b/src/content/repositories/FollowKeyRepository.ts
@@ -0,0 +1,35 @@
+export default interface FollowKeyRepository {
+ getKeys(): string[];
+
+ pushKey(key: string): void;
+
+ popKey(): void;
+
+ clearKeys(): void;
+
+ // eslint-disable-next-line semi
+}
+
+const current: {
+ keys: string[];
+} = {
+ keys: [],
+};
+
+export class FollowKeyRepositoryImpl implements FollowKeyRepository {
+ getKeys(): string[] {
+ return current.keys;
+ }
+
+ pushKey(key: string): void {
+ current.keys.push(key);
+ }
+
+ popKey(): void {
+ current.keys.pop();
+ }
+
+ clearKeys(): void {
+ current.keys = [];
+ }
+}
diff --git a/src/content/repositories/FollowMasterRepository.ts b/src/content/repositories/FollowMasterRepository.ts
new file mode 100644
index 0000000..a964953
--- /dev/null
+++ b/src/content/repositories/FollowMasterRepository.ts
@@ -0,0 +1,59 @@
+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;
+
+ // eslint-disable-next-line semi
+}
+
+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;
+ }
+}
+
diff --git a/src/content/repositories/FollowSlaveRepository.ts b/src/content/repositories/FollowSlaveRepository.ts
new file mode 100644
index 0000000..4c2de72
--- /dev/null
+++ b/src/content/repositories/FollowSlaveRepository.ts
@@ -0,0 +1,31 @@
+export default interface FollowSlaveRepository {
+ enableFollowMode(): void;
+
+ disableFollowMode(): void;
+
+ isFollowMode(): boolean;
+
+ // eslint-disable-next-line semi
+}
+
+const current: {
+ enabled: boolean;
+} = {
+ enabled: false,
+};
+
+export class FollowSlaveRepositoryImpl implements FollowSlaveRepository {
+ enableFollowMode(): void {
+ current.enabled = true;
+ }
+
+ disableFollowMode(): void {
+ current.enabled = false;
+ }
+
+ isFollowMode(): boolean {
+ return current.enabled;
+ }
+}
+
+