Combine system preview generation options (#2328)

This commit is contained in:
WithoutPants 2022-02-20 11:08:21 +11:00 committed by GitHub
parent d678283486
commit 3475a33aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 28 deletions

View File

@ -51,12 +51,14 @@ export const GenerateDialog: React.FC<ISceneGenerateDialog> = ({
return;
}
// combine the defaults with the system preview generation settings
if (configuration?.defaults.generate) {
const { generate } = configuration.defaults;
setOptions(withoutTypename(generate));
setConfigRead(true);
} else if (configuration?.general) {
// backwards compatibility
}
if (configuration?.general) {
const { general } = configuration;
setOptions((existing) => ({
...existing,

View File

@ -111,6 +111,7 @@ export const LibraryTasks: React.FC = () => {
type DialogOpenState = typeof dialogOpen;
const { configuration } = React.useContext(ConfigurationContext);
const [configRead, setConfigRead] = useState(false);
useEffect(() => {
if (!configuration?.defaults) {
@ -126,33 +127,41 @@ export const LibraryTasks: React.FC = () => {
setAutoTagOptions(withoutTypename(autoTag));
}
if (configuration?.defaults.generate) {
const { generate } = configuration.defaults;
setGenerateOptions(withoutTypename(generate));
} else if (configuration?.general) {
// backwards compatibility
const { general } = configuration;
setGenerateOptions((existing) => ({
...existing,
previewOptions: {
...existing.previewOptions,
previewSegments:
general.previewSegments ?? existing.previewOptions?.previewSegments,
previewSegmentDuration:
general.previewSegmentDuration ??
existing.previewOptions?.previewSegmentDuration,
previewExcludeStart:
general.previewExcludeStart ??
existing.previewOptions?.previewExcludeStart,
previewExcludeEnd:
general.previewExcludeEnd ??
existing.previewOptions?.previewExcludeEnd,
previewPreset:
general.previewPreset ?? existing.previewOptions?.previewPreset,
},
}));
// combine the defaults with the system preview generation settings
// only do this once
if (!configRead) {
if (configuration?.defaults.generate) {
const { generate } = configuration.defaults;
setGenerateOptions(withoutTypename(generate));
}
if (configuration?.general) {
const { general } = configuration;
setGenerateOptions((existing) => ({
...existing,
previewOptions: {
...existing.previewOptions,
previewSegments:
general.previewSegments ??
existing.previewOptions?.previewSegments,
previewSegmentDuration:
general.previewSegmentDuration ??
existing.previewOptions?.previewSegmentDuration,
previewExcludeStart:
general.previewExcludeStart ??
existing.previewOptions?.previewExcludeStart,
previewExcludeEnd:
general.previewExcludeEnd ??
existing.previewOptions?.previewExcludeEnd,
previewPreset:
general.previewPreset ?? existing.previewOptions?.previewPreset,
},
}));
}
setConfigRead(true);
}
}, [configuration]);
}, [configuration, configRead]);
function setDialogOpen(s: Partial<DialogOpenState>) {
setDialogOpenState((v) => {