mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-19 12:24:59 -04:00
Fixed frontend sync and translate missing hi and forced information
This commit is contained in:
parent
41541775e9
commit
26ce9d73e6
6 changed files with 49 additions and 7 deletions
|
@ -127,6 +127,8 @@ const SubtitleToolsMenu: FunctionComponent<Props> = ({
|
|||
type: s.type,
|
||||
language: s.language,
|
||||
path: s.path,
|
||||
hi: s.hi,
|
||||
forced: s.forced,
|
||||
};
|
||||
task.create(s.path, name, mutateAsync, { action, form });
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
import { useModals, withModal } from "@/modules/modals";
|
||||
import { task } from "@/modules/task";
|
||||
import { syncMaxOffsetSecondsOptions } from "@/pages/Settings/Subtitles/options";
|
||||
import { toPython } from "@/utilities";
|
||||
import { fromPython, toPython } from "@/utilities";
|
||||
|
||||
const TaskName = "Syncing Subtitle";
|
||||
|
||||
|
@ -109,6 +109,8 @@ interface FormValues {
|
|||
maxOffsetSeconds?: string;
|
||||
noFixFramerate: boolean;
|
||||
gss: boolean;
|
||||
hi?: boolean;
|
||||
forced?: boolean;
|
||||
}
|
||||
|
||||
const SyncSubtitleForm: FunctionComponent<Props> = ({
|
||||
|
@ -122,9 +124,11 @@ const SyncSubtitleForm: FunctionComponent<Props> = ({
|
|||
const { mutateAsync } = useSubtitleAction();
|
||||
const modals = useModals();
|
||||
|
||||
const mediaType = selections[0].type;
|
||||
const mediaId = selections[0].id;
|
||||
const subtitlesPath = selections[0].path;
|
||||
const subtitle = selections[0];
|
||||
|
||||
const mediaType = subtitle.type;
|
||||
const mediaId = subtitle.id;
|
||||
const subtitlesPath = subtitle.path;
|
||||
|
||||
const subtitles = useReferencedSubtitles(mediaType, mediaId, subtitlesPath);
|
||||
|
||||
|
@ -132,6 +136,8 @@ const SyncSubtitleForm: FunctionComponent<Props> = ({
|
|||
initialValues: {
|
||||
noFixFramerate: false,
|
||||
gss: false,
|
||||
hi: fromPython(subtitle.hi),
|
||||
forced: fromPython(subtitle.forced),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useEpisodeSubtitleModification } from "@/apis/hooks";
|
|||
import Language from "@/components/bazarr/Language";
|
||||
import SubtitleToolsMenu from "@/components/SubtitleToolsMenu";
|
||||
import { task, TaskGroup } from "@/modules/task";
|
||||
import { toPython } from "@/utilities";
|
||||
|
||||
interface Props {
|
||||
seriesId: number;
|
||||
|
@ -43,11 +44,13 @@ export const Subtitle: FunctionComponent<Props> = ({
|
|||
type: "episode",
|
||||
language: subtitle.code2,
|
||||
path: subtitle.path,
|
||||
forced: toPython(subtitle.forced),
|
||||
hi: toPython(subtitle.hi),
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}, [episodeId, subtitle.code2, subtitle.path]);
|
||||
}, [episodeId, subtitle.code2, subtitle.path, subtitle.forced, subtitle.hi]);
|
||||
|
||||
const ctx = (
|
||||
<Badge variant={variant}>
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Action, SimpleTable } from "@/components";
|
|||
import Language from "@/components/bazarr/Language";
|
||||
import SubtitleToolsMenu from "@/components/SubtitleToolsMenu";
|
||||
import { task, TaskGroup } from "@/modules/task";
|
||||
import { filterSubtitleBy } from "@/utilities";
|
||||
import { filterSubtitleBy, toPython } from "@/utilities";
|
||||
import { useProfileItemsToLanguages } from "@/utilities/languages";
|
||||
|
||||
const missingText = "Missing Subtitles";
|
||||
|
@ -95,11 +95,13 @@ const Table: FunctionComponent<Props> = ({ movie, profile, disabled }) => {
|
|||
path,
|
||||
id: movie.radarrId,
|
||||
language: code2,
|
||||
forced: toPython(forced),
|
||||
hi: toPython(hi),
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}, [code2, path]);
|
||||
}, [code2, path, forced, hi]);
|
||||
|
||||
if (movie === null) {
|
||||
return null;
|
||||
|
|
25
frontend/src/utilities/index.test.ts
Normal file
25
frontend/src/utilities/index.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { fromPython, toPython } from "@/utilities/index";
|
||||
|
||||
describe("fromPythonConversion", () => {
|
||||
it("should convert a true value", () => {
|
||||
expect(fromPython("True")).toBe(true);
|
||||
});
|
||||
|
||||
it("should convert a false value", () => {
|
||||
expect(fromPython("False")).toBe(false);
|
||||
});
|
||||
|
||||
it("should convert an undefined value", () => {
|
||||
expect(fromPython(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("toPythonConversion", () => {
|
||||
it("should convert a true value", () => {
|
||||
expect(toPython(true)).toBe("True");
|
||||
});
|
||||
|
||||
it("should convert a false value", () => {
|
||||
expect(toPython(false)).toBe("False");
|
||||
});
|
||||
});
|
|
@ -59,6 +59,10 @@ export function filterSubtitleBy(
|
|||
}
|
||||
}
|
||||
|
||||
export function fromPython(value: PythonBoolean | undefined): boolean {
|
||||
return value === "True";
|
||||
}
|
||||
|
||||
export function toPython(value: boolean): PythonBoolean {
|
||||
return value ? "True" : "False";
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue