Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions apps/obsidian/src/utils/publishNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,30 @@ export const publishNode = async ({
plugin,
file,
frontmatter,
republish,
}: {
plugin: DiscourseGraphPlugin;
file: TFile;
frontmatter: FrontMatterCache;
republish?: boolean;
}): Promise<void> => {
const client = await getLoggedInClient(plugin);
if (!client) throw new Error("Cannot get client");
const myGroups = new Set(await getAvailableGroupIds(client));
if (myGroups.size === 0) throw new Error("Cannot get group");
const existingPublish =
(frontmatter.publishedToGroups as undefined | string[]) || [];
if (!republish) await syncAllNodesAndRelations(plugin);
const commonGroups = existingPublish.filter((g) => myGroups.has(g));
// temporary single-group assumption
const myGroup = (commonGroups.length > 0 ? commonGroups : [...myGroups])[0]!;
return await publishNodeToGroup({ plugin, file, frontmatter, myGroup });
return await publishNodeToGroup({
plugin,
file,
frontmatter,
myGroup,
republish,
});
};

export const ensurePublishedRelationsAccuracy = async ({
Expand Down Expand Up @@ -413,11 +422,13 @@ export const publishNodeToGroup = async ({
file,
frontmatter,
myGroup,
republish,
}: {
plugin: DiscourseGraphPlugin;
file: TFile;
frontmatter: FrontMatterCache;
myGroup: string;
republish?: boolean;
}): Promise<void> => {
const nodeId = frontmatter.nodeInstanceId as string | undefined;
if (!nodeId) throw new Error("Please sync the node first");
Expand Down Expand Up @@ -464,7 +475,8 @@ export const publishNodeToGroup = async ({
);

const skipPublishAccess =
existingPublish.includes(myGroup) && lastModified <= lastModifiedDb;
republish ||
(existingPublish.includes(myGroup) && lastModified <= lastModifiedDb);

if (!skipPublishAccess) {
const publishSpaceResponse = await client.from("SpaceAccess").upsert(
Expand Down
1 change: 1 addition & 0 deletions apps/obsidian/src/utils/syncDgNodesToSupabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ const syncPublishedNodesAssets = async (
plugin,
file: node.file,
frontmatter: node.frontmatter as FrontMatterCache,
republish: true,
});
} catch (error) {
console.error(
Expand Down
Loading