Fixes bug with updating relationships when an item is added
This commit is contained in:
@@ -35,10 +35,6 @@ export function RelationshipList({
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
const doc = docResult.value.doc;
|
||||
|
||||
console.info("Rendering relationship list: ", relationshipType);
|
||||
|
||||
const relationshipResult = docResult.value.relationships[relationshipType];
|
||||
|
||||
const relationship =
|
||||
@@ -60,7 +56,6 @@ export function RelationshipList({
|
||||
try {
|
||||
// Check for existing relationship
|
||||
if (relationship) {
|
||||
console.debug("Adding to existing relationship", relationship.id);
|
||||
const updatedRelationship: Relationship = await pb
|
||||
.collection("relationships")
|
||||
.update(relationship.id, {
|
||||
@@ -68,11 +63,10 @@ export function RelationshipList({
|
||||
});
|
||||
dispatch({
|
||||
type: "setRelationship",
|
||||
docId: doc.id,
|
||||
docId: root.id,
|
||||
relationship: updatedRelationship,
|
||||
});
|
||||
} else {
|
||||
console.debug("Creating new relationship");
|
||||
const updatedRelationship: Relationship = await pb
|
||||
.collection("relationships")
|
||||
.create({
|
||||
@@ -82,7 +76,7 @@ export function RelationshipList({
|
||||
});
|
||||
dispatch({
|
||||
type: "setRelationship",
|
||||
docId: doc.id,
|
||||
docId: root.id,
|
||||
relationship: updatedRelationship,
|
||||
});
|
||||
}
|
||||
@@ -99,7 +93,6 @@ export function RelationshipList({
|
||||
|
||||
try {
|
||||
if (relationship) {
|
||||
console.debug("Removing from existing relationship", relationship.id);
|
||||
const updatedRelationship: Relationship = await pb
|
||||
.collection("relationships")
|
||||
.update(relationship.id, {
|
||||
@@ -107,7 +100,7 @@ export function RelationshipList({
|
||||
});
|
||||
dispatch({
|
||||
type: "setRelationship",
|
||||
docId: doc.id,
|
||||
docId: root.id,
|
||||
relationship: updatedRelationship,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,8 +11,6 @@ import { Route as RelationshipRoute } from "@/routes/_app/_authenticated/documen
|
||||
export function DocumentView({ documentId }: { documentId: DocumentId }) {
|
||||
const { docResult } = useDocument(documentId);
|
||||
|
||||
console.info(`Rendering document: `, docResult);
|
||||
|
||||
if (docResult?.type !== "ready") {
|
||||
return <Loader />;
|
||||
}
|
||||
@@ -50,16 +48,14 @@ export function DocumentView({ documentId }: { documentId: DocumentId }) {
|
||||
<ul className="flex flex-row gap-1">
|
||||
{relationshipList.map((relationshipType) => (
|
||||
<Link
|
||||
key={relationshipType}
|
||||
to={RelationshipRoute.to}
|
||||
params={{
|
||||
documentId,
|
||||
relationshipType,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
key={relationshipType}
|
||||
className="px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500 data-selected:bg-violet-900 data-selected:border-violet-700 whitespace-nowrap"
|
||||
>
|
||||
<div className="px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500 data-selected:bg-violet-900 data-selected:border-violet-700 whitespace-nowrap">
|
||||
{displayName(relationshipType)} (
|
||||
{relationshipCounts[relationshipType] ?? 0})
|
||||
</div>
|
||||
|
||||
@@ -13,8 +13,6 @@ export function RelatedDocumentList({ documentId, relationshipType }: Props) {
|
||||
|
||||
const { cache } = useDocumentCache();
|
||||
|
||||
console.log(documentId, docResult, cache);
|
||||
|
||||
if (docResult?.type !== "ready") {
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user