mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Thumbnail scrubber improvements (#4081)
* Remove deps from useDebounce hook * Add useThrottle hook * Throttle preview scrubber * Scrubber improvements
This commit is contained in:
@@ -134,7 +134,7 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
setUI(data.configuration.ui);
|
||||
}, [data, error]);
|
||||
|
||||
const resetSuccess = useDebounce(() => setUpdateSuccess(undefined), [], 4000);
|
||||
const resetSuccess = useDebounce(() => setUpdateSuccess(undefined), 4000);
|
||||
|
||||
const onSuccess = useCallback(() => {
|
||||
setUpdateSuccess(true);
|
||||
@@ -158,7 +158,6 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateGeneralConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
|
||||
@@ -208,7 +207,6 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateInterfaceConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
|
||||
@@ -258,7 +256,6 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateDefaultsConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
|
||||
@@ -308,7 +305,6 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateScrapingConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
|
||||
@@ -342,25 +338,21 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
}
|
||||
|
||||
// saves the configuration if no further changes are made after a half second
|
||||
const saveDLNAConfig = useDebounce(
|
||||
async (input: GQL.ConfigDlnaInput) => {
|
||||
try {
|
||||
setUpdateSuccess(undefined);
|
||||
await updateDLNAConfig({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
const saveDLNAConfig = useDebounce(async (input: GQL.ConfigDlnaInput) => {
|
||||
try {
|
||||
setUpdateSuccess(undefined);
|
||||
await updateDLNAConfig({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
|
||||
setPendingDLNA(undefined);
|
||||
onSuccess();
|
||||
} catch (e) {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateDLNAConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
setPendingDLNA(undefined);
|
||||
onSuccess();
|
||||
} catch (e) {
|
||||
setSaveError(e);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pendingDLNA) {
|
||||
@@ -392,25 +384,21 @@ export const SettingsContext: React.FC = ({ children }) => {
|
||||
}
|
||||
|
||||
// saves the configuration if no further changes are made after a half second
|
||||
const saveUIConfig = useDebounce(
|
||||
async (input: IUIConfig) => {
|
||||
try {
|
||||
setUpdateSuccess(undefined);
|
||||
await updateUIConfig({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
const saveUIConfig = useDebounce(async (input: IUIConfig) => {
|
||||
try {
|
||||
setUpdateSuccess(undefined);
|
||||
await updateUIConfig({
|
||||
variables: {
|
||||
input,
|
||||
},
|
||||
});
|
||||
|
||||
setPendingUI(undefined);
|
||||
onSuccess();
|
||||
} catch (e) {
|
||||
setSaveError(e);
|
||||
}
|
||||
},
|
||||
[updateUIConfig, onSuccess],
|
||||
500
|
||||
);
|
||||
setPendingUI(undefined);
|
||||
onSuccess();
|
||||
} catch (e) {
|
||||
setSaveError(e);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
useEffect(() => {
|
||||
if (!pendingUI) {
|
||||
|
||||
Reference in New Issue
Block a user