1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-26 17:47:20 +00:00

Fix items are not updated when using mass editor

This commit is contained in:
LASER-Yi 2021-09-01 11:30:28 +08:00
parent ccd5473598
commit 60e2732f48
2 changed files with 7 additions and 13 deletions

View file

@ -6,7 +6,6 @@ import React, {
MouseEvent,
PropsWithChildren,
useCallback,
useRef,
useState,
} from "react";
import { Button } from "react-bootstrap";
@ -59,16 +58,13 @@ export function ContentHeaderAsyncButton<T extends () => Promise<any>>(
const [updating, setUpdate] = useState(false);
const promiseRef = useRef(promise);
const successRef = useRef(onSuccess);
const click = useCallback(() => {
setUpdate(true);
promiseRef.current().then((val) => {
promise().then((val) => {
setUpdate(false);
successRef.current && successRef.current(val);
onSuccess && onSuccess(val);
});
}, [successRef, promiseRef]);
}, [onSuccess, promise]);
return (
<ContentHeaderButton

View file

@ -26,17 +26,15 @@ export const Chips: FunctionComponent<ChipsProps> = ({
const input = useRef<HTMLInputElement>(null);
const changeRef = useRef(onChange);
const addChip = useCallback(
(value: string) => {
setChips((cp) => {
const newChips = [...cp, value];
changeRef.current && changeRef.current(newChips);
onChange && onChange(newChips);
return newChips;
});
},
[changeRef]
[onChange]
);
const removeChip = useCallback(
@ -46,14 +44,14 @@ export const Chips: FunctionComponent<ChipsProps> = ({
if (index !== -1) {
const newChips = [...cp];
newChips.splice(index, 1);
changeRef.current && changeRef.current(newChips);
onChange && onChange(newChips);
return newChips;
} else {
return cp;
}
});
},
[changeRef]
[onChange]
);
const clearInput = useCallback(() => {