namespace autotag config key and memoize trigger hook

This commit is contained in:
Gykes 2026-04-23 00:08:06 -07:00
parent 76140b1437
commit 9aac8b30ad
3 changed files with 11 additions and 8 deletions

View file

@ -237,7 +237,7 @@ const (
DisableDropdownCreateMovie = "disable_dropdown_create.movie"
DisableDropdownCreateGallery = "disable_dropdown_create.gallery"
DisableAutoTagWarning = "disable_auto_tag_warning"
DisableAutoTagWarning = "auto_tag.disable_warning"
HandyKey = "handy_key"
FunscriptOffset = "funscript_offset"

View file

@ -204,7 +204,8 @@ export const LibraryTasks: React.FC = () => {
const onAutoTagClick = useAutoTagTrigger(
() => runAutoTag(),
() => setDialogOpen({ autoTagAlert: true })
() => setDialogOpen({ autoTagAlert: true }),
iface.disableAutoTagWarning
);
function renderScanDialog() {

View file

@ -1,17 +1,19 @@
import { useCallback } from "react";
import { useConfigurationContext } from "./Config";
// Centralises the "skip warning" check so every entry point to auto tag
// consults the same interface flag.
export function useAutoTagTrigger(
onRun: () => void,
onOpenConfirm: () => void
onOpenConfirm: () => void,
override?: boolean | null
) {
const { configuration } = useConfigurationContext();
return () => {
if (configuration?.interface.disableAutoTagWarning) {
const disabled =
override ?? configuration?.interface.disableAutoTagWarning ?? false;
return useCallback(() => {
if (disabled) {
onRun();
return;
}
onOpenConfirm();
};
}, [disabled, onRun, onOpenConfirm]);
}