Skip to content

Commit d34f8dd

Browse files
committed
also publish Concept if any
1 parent f1ae83c commit d34f8dd

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

apps/obsidian/src/utils/publishNode.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@ export const publishNode = async ({
4343
if (publishResponse.error && publishResponse.error.code !== "23505")
4444
// 23505 is duplicate key, which counts as a success.
4545
throw publishResponse.error;
46+
// check if there is a corresponding concept.
47+
const conceptIdResponse = await client
48+
.from("Concept")
49+
.select("id")
50+
.eq("represented_by_id", contentId)
51+
.maybeSingle();
52+
if (conceptIdResponse.error) throw conceptIdResponse.error;
53+
if (conceptIdResponse.data) {
54+
const publishConceptResponse = await client.from("ConceptAccess").insert({
55+
/* eslint-disable @typescript-eslint/naming-convention */
56+
account_uid: myGroup,
57+
concept_id: conceptIdResponse.data.id,
58+
/* eslint-enable @typescript-eslint/naming-convention */
59+
});
60+
if (
61+
publishConceptResponse.error &&
62+
publishConceptResponse.error.code !== "23505"
63+
)
64+
// 23505 is duplicate key, which counts as a success.
65+
throw publishConceptResponse.error;
66+
}
4667
await plugin.app.fileManager.processFrontMatter(
4768
file,
4869
(fm: Record<string, unknown>) => {

0 commit comments

Comments
 (0)