diff --git a/frontend/src/components/Playback/SubtitleTrack.vue b/frontend/src/components/Playback/SubtitleTrack.vue
index ed5f31c3..b7fdf400 100644
--- a/frontend/src/components/Playback/SubtitleTrack.vue
+++ b/frontend/src/components/Playback/SubtitleTrack.vue
@@ -17,7 +17,7 @@
diff --git a/frontend/src/store/client-settings.ts b/frontend/src/store/client-settings/client-settings.ts
similarity index 70%
rename from frontend/src/store/client-settings.ts
rename to frontend/src/store/client-settings/client-settings.ts
index ddf33627..a829b3d2 100644
--- a/frontend/src/store/client-settings.ts
+++ b/frontend/src/store/client-settings/client-settings.ts
@@ -8,7 +8,6 @@ import { remote } from '@/plugins/remote';
import { vuetify } from '@/plugins/vuetify';
import { sealed } from '@/utils/validation';
import { SyncedStore } from '@/store/super/synced-store';
-import { useFont } from '@/composables/use-font';
/**
* == INTERFACES AND TYPES ==
@@ -18,20 +17,12 @@ import { useFont } from '@/composables/use-font';
export interface ClientSettingsState {
darkMode: 'auto' | boolean;
locale: string;
- subtitleAppearance: {
- fontFamily: string;
- fontSize: number;
- positionFromBottom: number;
- backdrop: boolean;
- stroke: boolean;
- };
}
@sealed
class ClientSettingsStore extends SyncedStore {
private readonly _browserPrefersDark = usePreferredDark();
private readonly _navigatorLanguage = useNavigatorLanguage();
- private readonly _bodyFont = useFont();
private readonly _BROWSER_LANGUAGE = computed(() => {
const rawString = this._navigatorLanguage.language.value ?? '';
/**
@@ -42,8 +33,6 @@ class ClientSettingsStore extends SyncedStore {
return cleanString[0];
});
- private readonly _BODY_FONT = this._bodyFont.currentFont;
-
public set locale(newVal: string) {
this._state.locale
= i18n.availableLocales.includes(newVal) && newVal !== 'auto'
@@ -63,14 +52,6 @@ class ClientSettingsStore extends SyncedStore {
return this._state.darkMode;
}
- public set subtitleAppearance(newVal: ClientSettingsState['subtitleAppearance']) {
- this._state.subtitleAppearance = newVal;
- }
-
- public get subtitleAppearance(): ClientSettingsState['subtitleAppearance'] {
- return this._state.subtitleAppearance;
- }
-
public readonly currentTheme = computed(() => {
const dark = 'dark';
const light = 'light';
@@ -89,24 +70,10 @@ class ClientSettingsStore extends SyncedStore {
vuetify.locale.current.value = i18n.locale.value;
};
- private readonly _updateSubtitleFontFamily = (): void => {
- this.subtitleAppearance.fontFamily
- = this.subtitleAppearance.fontFamily === 'auto'
- ? this._BODY_FONT.value
- : this.subtitleAppearance.fontFamily;
- };
-
public constructor() {
super('clientSettings', {
darkMode: 'auto',
- locale: 'auto',
- subtitleAppearance: {
- fontFamily: 'auto',
- fontSize: 1.5,
- positionFromBottom: 10,
- backdrop: true,
- stroke: false
- }
+ locale: 'auto'
}, 'localStorage');
/**
* == WATCHERS ==
@@ -120,11 +87,6 @@ class ClientSettingsStore extends SyncedStore {
this._updateLocale
);
- /**
- * Font family changes
- */
- watchImmediate(this._BODY_FONT, this._updateSubtitleFontFamily);
-
/**
* Vuetify theme change
*/
@@ -146,4 +108,4 @@ class ClientSettingsStore extends SyncedStore {
}
}
-export const clientSettings = new ClientSettingsStore();
+export default new ClientSettingsStore();
diff --git a/frontend/src/store/client-settings/index.ts b/frontend/src/store/client-settings/index.ts
new file mode 100644
index 00000000..f698c558
--- /dev/null
+++ b/frontend/src/store/client-settings/index.ts
@@ -0,0 +1,2 @@
+export { default as clientSettings } from '@/store/client-settings/client-settings.ts';
+export { default as subtitleSettings } from '@/store/client-settings/subtitle-settings.ts';
diff --git a/frontend/src/store/client-settings/subtitle-settings.ts b/frontend/src/store/client-settings/subtitle-settings.ts
new file mode 100644
index 00000000..55f943d1
--- /dev/null
+++ b/frontend/src/store/client-settings/subtitle-settings.ts
@@ -0,0 +1,74 @@
+import { watchImmediate } from '@vueuse/core';
+import { watch } from 'vue';
+import { remote } from '@/plugins/remote';
+import { sealed } from '@/utils/validation';
+import { SyncedStore } from '@/store/super/synced-store';
+import { useFont } from '@/composables/use-font';
+
+/**
+ * == INTERFACES AND TYPES ==
+ */
+
+interface SubtitleApperance {
+ fontFamily: string;
+ fontSize: number;
+ positionFromBottom: number;
+ backdrop: boolean;
+ stroke: boolean;
+}
+
+export interface SubtitleSettingsState {
+ subtitleAppearance: SubtitleApperance;
+}
+
+@sealed
+class SubtitleSettingsStore extends SyncedStore {
+ private readonly _bodyFont = useFont();
+
+ public set subtitleAppearance(newVal: SubtitleSettingsState['subtitleAppearance']) {
+ this._state.subtitleAppearance = newVal;
+ }
+
+ public get subtitleAppearance(): SubtitleSettingsState['subtitleAppearance'] {
+ return this._state.subtitleAppearance;
+ }
+
+ private readonly _updateSubtitleFontFamily = (): void => {
+ this.subtitleAppearance.fontFamily
+ = this.subtitleAppearance.fontFamily === 'auto'
+ ? this._bodyFont.currentFont.value
+ : this.subtitleAppearance.fontFamily;
+ };
+
+ public constructor() {
+ super('subtitleSettings', {
+ subtitleAppearance: {
+ fontFamily: 'auto',
+ fontSize: 1.5,
+ positionFromBottom: 10,
+ backdrop: true,
+ stroke: false
+ }
+ }, 'localStorage');
+
+ /**
+ * == WATCHERS ==
+ */
+
+ /**
+ * Font family changes
+ */
+ watchImmediate(this._bodyFont.currentFont, this._updateSubtitleFontFamily);
+
+ watch(
+ () => remote.auth.currentUser,
+ () => {
+ if (!remote.auth.currentUser) {
+ this._reset();
+ }
+ }, { flush: 'post' }
+ );
+ }
+}
+
+export default new SubtitleSettingsStore();
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index 7ac3ad06..2614a0dc 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -20,6 +20,7 @@
"verbatimModuleSyntax": true,
"incremental": true,
"tsBuildInfoFile": "../node_modules/.cache/tsconfig.tsbuildinfo",
+ "allowImportingTsExtensions": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]