aboutsummaryrefslogtreecommitdiff
path: root/src/content/repositories
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-05-19 09:26:52 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2019-05-19 09:26:52 +0900
commite0c4182f14f908d13c8c814c7bc2b48a1791f881 (patch)
treea277179d51013c4a2384f076197a1dbcc442d2d0 /src/content/repositories
parent5b7f7f5dbd94b5bce7aee4667add187ffb9944f2 (diff)
Follow as a clean architecture
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;
+ }
+}
+
+