mirror of
https://github.com/movie-web/movie-web.git
synced 2024-12-27 08:21:51 +01:00
fix migration
This commit is contained in:
parent
2178057633
commit
5d8f03b859
@ -230,7 +230,7 @@ registerProvider({
|
|||||||
const sub = subtitle;
|
const sub = subtitle;
|
||||||
sub.subtitles = subtitle.subtitles.filter((subFile: any) => {
|
sub.subtitles = subtitle.subtitles.filter((subFile: any) => {
|
||||||
const extension = subFile.file_path.substring(
|
const extension = subFile.file_path.substring(
|
||||||
sub.file_path.length - 3
|
subFile.file_path.length - 3
|
||||||
);
|
);
|
||||||
return [MWCaptionType.SRT, MWCaptionType.VTT].includes(extension);
|
return [MWCaptionType.SRT, MWCaptionType.VTT].includes(extension);
|
||||||
});
|
});
|
||||||
|
@ -5,6 +5,7 @@ import { SettingsStore } from "./store";
|
|||||||
import { MWSettingsData } from "./types";
|
import { MWSettingsData } from "./types";
|
||||||
|
|
||||||
interface MWSettingsDataSetters {
|
interface MWSettingsDataSetters {
|
||||||
|
setLanguage(language: LangCode): void;
|
||||||
setCaptionLanguage(language: LangCode): void;
|
setCaptionLanguage(language: LangCode): void;
|
||||||
setCaptionDelay(delay: number): void;
|
setCaptionDelay(delay: number): void;
|
||||||
setCaptionColor(color: string): void;
|
setCaptionColor(color: string): void;
|
||||||
@ -21,6 +22,14 @@ export function SettingsProvider(props: { children: ReactNode }) {
|
|||||||
const context: MWSettingsDataWrapper = useMemo(() => {
|
const context: MWSettingsDataWrapper = useMemo(() => {
|
||||||
const settingsContext: MWSettingsDataWrapper = {
|
const settingsContext: MWSettingsDataWrapper = {
|
||||||
...settings,
|
...settings,
|
||||||
|
setLanguage(language) {
|
||||||
|
setSettings((oldSettings) => {
|
||||||
|
return {
|
||||||
|
...oldSettings,
|
||||||
|
language,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
setCaptionLanguage(language) {
|
setCaptionLanguage(language) {
|
||||||
setSettings((oldSettings) => {
|
setSettings((oldSettings) => {
|
||||||
const captionSettings = oldSettings.captionSettings;
|
const captionSettings = oldSettings.captionSettings;
|
||||||
|
@ -20,6 +20,7 @@ export const SettingsStore = createVersionedStore<MWSettingsData>()
|
|||||||
},
|
},
|
||||||
migrate(data: MWSettingsDataV1): MWSettingsData {
|
migrate(data: MWSettingsDataV1): MWSettingsData {
|
||||||
return {
|
return {
|
||||||
|
language: data.language,
|
||||||
captionSettings: {
|
captionSettings: {
|
||||||
language: "none",
|
language: "none",
|
||||||
...data.captionSettings,
|
...data.captionSettings,
|
||||||
@ -31,6 +32,7 @@ export const SettingsStore = createVersionedStore<MWSettingsData>()
|
|||||||
version: 1,
|
version: 1,
|
||||||
create(): MWSettingsData {
|
create(): MWSettingsData {
|
||||||
return {
|
return {
|
||||||
|
language: "en",
|
||||||
captionSettings: {
|
captionSettings: {
|
||||||
delay: 0,
|
delay: 0,
|
||||||
language: "none",
|
language: "none",
|
||||||
|
@ -31,5 +31,6 @@ export interface MWSettingsDataV1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface MWSettingsData {
|
export interface MWSettingsData {
|
||||||
|
language: LangCode;
|
||||||
captionSettings: CaptionSettings;
|
captionSettings: CaptionSettings;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user