feat(boards): wire board cache scope for query persistence
Call setActiveQueryCacheBoardId when board context initializes so the client-side persister knows which board to scope cache reads/writes to.
This commit is contained in:
1 parent
6c623a3a2d
commit
f7f6d1e382
1 file changed
+13
@@ -6,6 +6,7 @@ import { usePathname } from "next/navigation";
|
|||||||
|
|
||||||
import type { RouterOutputs } from "@homarr/api";
|
import type { RouterOutputs } from "@homarr/api";
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
|
import { getActiveQueryCacheBoardId, setActiveQueryCacheBoardId } from "@homarr/api/query-cache";
|
||||||
|
|
||||||
import { updateBoardName } from "./updater";
|
import { updateBoardName } from "./updater";
|
||||||
|
|
||||||
@@ -28,6 +29,8 @@ export const BoardProvider = ({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setActiveQueryCacheBoardId(data.id);
|
||||||
|
|
||||||
// Update the board name so it can be used within updateBoard method
|
// Update the board name so it can be used within updateBoard method
|
||||||
updateBoardName(initialBoard.name);
|
updateBoardName(initialBoard.name);
|
||||||
|
|
||||||
@@ -42,6 +45,16 @@ export const BoardProvider = ({
|
|||||||
};
|
};
|
||||||
}, [pathname, utils, initialBoard.name]);
|
}, [pathname, utils, initialBoard.name]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setActiveQueryCacheBoardId(data.id);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (getActiveQueryCacheBoardId() === data.id) {
|
||||||
|
setActiveQueryCacheBoardId(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [data.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BoardContext.Provider
|
<BoardContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
|||||||
Reference in new issue
Block a user