mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-04 16:47:40 +01:00
Reset caption specific settings
Co-authored-by: William Oldham <github@binaryoverload.co.uk>
This commit is contained in:
parent
e7d6f4559e
commit
8015ec5a92
2 changed files with 12 additions and 1 deletions
|
@ -7,6 +7,9 @@ import { useSubtitleStore } from "@/stores/subtitles";
|
||||||
export function useCaptions() {
|
export function useCaptions() {
|
||||||
const setLanguage = useSubtitleStore((s) => s.setLanguage);
|
const setLanguage = useSubtitleStore((s) => s.setLanguage);
|
||||||
const enabled = useSubtitleStore((s) => s.enabled);
|
const enabled = useSubtitleStore((s) => s.enabled);
|
||||||
|
const resetSubtitleSpecificSettings = useSubtitleStore(
|
||||||
|
(s) => s.resetSubtitleSpecificSettings
|
||||||
|
);
|
||||||
const setCaption = usePlayerStore((s) => s.setCaption);
|
const setCaption = usePlayerStore((s) => s.setCaption);
|
||||||
const lastSelectedLanguage = useSubtitleStore((s) => s.lastSelectedLanguage);
|
const lastSelectedLanguage = useSubtitleStore((s) => s.lastSelectedLanguage);
|
||||||
const captionList = usePlayerStore((s) => s.captionList);
|
const captionList = usePlayerStore((s) => s.captionList);
|
||||||
|
@ -21,9 +24,10 @@ export function useCaptions() {
|
||||||
srtData,
|
srtData,
|
||||||
url: caption.url,
|
url: caption.url,
|
||||||
});
|
});
|
||||||
|
resetSubtitleSpecificSettings();
|
||||||
setLanguage(language);
|
setLanguage(language);
|
||||||
},
|
},
|
||||||
[setLanguage, captionList, setCaption]
|
[setLanguage, captionList, setCaption, resetSubtitleSpecificSettings]
|
||||||
);
|
);
|
||||||
|
|
||||||
const disable = useCallback(async () => {
|
const disable = useCallback(async () => {
|
||||||
|
|
|
@ -34,6 +34,7 @@ export interface SubtitleStore {
|
||||||
setOverrideCasing(enabled: boolean): void;
|
setOverrideCasing(enabled: boolean): void;
|
||||||
setDelay(delay: number): void;
|
setDelay(delay: number): void;
|
||||||
importSubtitleLanguage(lang: string | null): void;
|
importSubtitleLanguage(lang: string | null): void;
|
||||||
|
resetSubtitleSpecificSettings(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSubtitleStore = create(
|
export const useSubtitleStore = create(
|
||||||
|
@ -51,6 +52,12 @@ export const useSubtitleStore = create(
|
||||||
backgroundOpacity: 0.5,
|
backgroundOpacity: 0.5,
|
||||||
size: 1,
|
size: 1,
|
||||||
},
|
},
|
||||||
|
resetSubtitleSpecificSettings() {
|
||||||
|
set((s) => {
|
||||||
|
s.delay = 0;
|
||||||
|
s.overrideCasing = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
updateStyling(newStyling) {
|
updateStyling(newStyling) {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
if (newStyling.backgroundOpacity !== undefined)
|
if (newStyling.backgroundOpacity !== undefined)
|
||||||
|
|
Loading…
Reference in a new issue