Completes the three-panel layout
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// SecretRow.tsx
|
||||
// Displays a single secret with discovered checkbox and text.
|
||||
import { pb } from "@/lib/pocketbase";
|
||||
import type { Secret, Session } from "@/lib/types";
|
||||
import type { AnyDocument, Secret } from "@/lib/types";
|
||||
import { useState } from "react";
|
||||
|
||||
/**
|
||||
@@ -10,10 +10,10 @@ import { useState } from "react";
|
||||
*/
|
||||
export const SecretToggleRow = ({
|
||||
secret,
|
||||
session,
|
||||
root,
|
||||
}: {
|
||||
secret: Secret;
|
||||
session?: Session;
|
||||
root?: AnyDocument;
|
||||
}) => {
|
||||
const [checked, setChecked] = useState(
|
||||
!!(secret.data as any)?.secret?.discovered,
|
||||
@@ -36,7 +36,7 @@ export const SecretToggleRow = ({
|
||||
},
|
||||
},
|
||||
});
|
||||
if (session || !newChecked) {
|
||||
if (root || !newChecked) {
|
||||
// If the session exists or the element is being unchecked, remove any
|
||||
// existing discoveredIn relationship
|
||||
const rels = await pb.collection("relationships").getList(1, 1, {
|
||||
@@ -46,11 +46,11 @@ export const SecretToggleRow = ({
|
||||
await pb.collection("relationships").delete(rels.items[0].id);
|
||||
}
|
||||
}
|
||||
if (session) {
|
||||
if (root) {
|
||||
if (newChecked) {
|
||||
await pb.collection("relationships").create({
|
||||
primary: secret.id,
|
||||
secondary: [session.id],
|
||||
secondary: [root.id],
|
||||
type: "discoveredIn",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user