mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
namespace autotag config key and memoize trigger hook
This commit is contained in:
parent
76140b1437
commit
9aac8b30ad
3 changed files with 11 additions and 8 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ export const LibraryTasks: React.FC = () => {
|
|||
|
||||
const onAutoTagClick = useAutoTagTrigger(
|
||||
() => runAutoTag(),
|
||||
() => setDialogOpen({ autoTagAlert: true })
|
||||
() => setDialogOpen({ autoTagAlert: true }),
|
||||
iface.disableAutoTagWarning
|
||||
);
|
||||
|
||||
function renderScanDialog() {
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue