Pass whole updated set instead of just its id
Since we already have the whole updated set, might as well pass it around instead of re-fetching it.
This commit is contained in:
parent
103ae5587d
commit
386a9a7bb2
|
@ -105,7 +105,7 @@ export default function EditSet() {
|
|||
const saved = await setRepo.save(newSet);
|
||||
if (typeof set.id !== "number") return added(saved);
|
||||
if (createdDirty) navigate("Sets", { reset: saved.id });
|
||||
else navigate("Sets", { refresh: saved.id });
|
||||
else navigate("Sets", { refresh: saved });
|
||||
};
|
||||
|
||||
const changeImage = useCallback(async () => {
|
||||
|
|
|
@ -29,10 +29,11 @@ export default function SetList() {
|
|||
const { params } = useRoute<RouteProp<HomePageParams, "Sets">>();
|
||||
const [term, setTerm] = useState(params?.search || "");
|
||||
|
||||
const refresh = async (id: number) => {
|
||||
const refresh = async (gymSet: GymSet) => {
|
||||
if (!sets) return;
|
||||
const set = await setRepo.findOne({ where: { id } });
|
||||
let newSets = sets.map((oldSet) => (oldSet.id === id ? set : oldSet));
|
||||
const newSets = sets.map((oldSet) =>
|
||||
oldSet.id === gymSet.id ? gymSet : oldSet
|
||||
);
|
||||
setSets(newSets);
|
||||
};
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ export type HomePageParams = {
|
|||
search?: string;
|
||||
|
||||
/**
|
||||
* Reload the specified set by ID.
|
||||
* Update the specified set
|
||||
*/
|
||||
refresh?: number;
|
||||
refresh?: GymSet;
|
||||
|
||||
/**
|
||||
* Reload the list with limit = 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user