Sets up global cache and uses it to fetch sessions
This commit is contained in:
@@ -83,7 +83,7 @@ export function RelationshipList({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ["relationship", relationshipType, root.id],
|
||||
});
|
||||
setItems((prev) => [...prev, doc]);
|
||||
setItems((prev) => [doc, ...prev]);
|
||||
} catch (e: any) {
|
||||
setError(e?.message || "Failed to add document to relationship.");
|
||||
} finally {
|
||||
@@ -99,9 +99,7 @@ export function RelationshipList({
|
||||
if (relationshipId) {
|
||||
console.debug("Removing from existing relationship", relationshipId);
|
||||
await pb.collection("relationships").update(relationshipId, {
|
||||
secondary: items
|
||||
.map((item) => item.id)
|
||||
.filter((id) => id !== documentId),
|
||||
"secondary-": documentId,
|
||||
});
|
||||
}
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
import { AutoSaveTextarea } from "@/components/AutoSaveTextarea";
|
||||
import { useCache } from "@/context/cache/CacheContext";
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import type { Session } from "@/lib/types";
|
||||
|
||||
export const SessionEditForm = ({ session }: { session: Session }) => {
|
||||
const cache = useCache();
|
||||
async function saveStrongStart(strongStart: string) {
|
||||
await pb.collection("documents").update(session.id, {
|
||||
data: {
|
||||
...session.data,
|
||||
strongStart,
|
||||
},
|
||||
});
|
||||
const freshRecord: Session = await pb
|
||||
.collection("documents")
|
||||
.update(session.id, {
|
||||
data: {
|
||||
...session.data,
|
||||
strongStart,
|
||||
},
|
||||
});
|
||||
cache.set(freshRecord);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user