Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(pages): send public visibility when a page is shared again

erywime4a51ac47465
diff --git a/src/components/app/PageTools.test.ts b/src/components/app/PageTools.test.ts
index ec19c638d5..ee3f5da61e 100644
--- a/src/components/app/PageTools.test.ts
+++ b/src/components/app/PageTools.test.ts
@@ -174,7 +174,7 @@ describe("a bot's page in the chat", () => {
await render(row(payload()));
await click("Share", card());
await settle();
- expect(posts("/app/publish")).toEqual([{ rev: 0 }]);
+ expect(posts("/app/publish")).toEqual([{ rev: 0, visibility: "public" }]);
await render(row(payload(), LIVE));
expect(card().querySelector("[data-page-link]")?.textContent).toContain(LINK);
expect(button("Copy link", card())).toBeDefined();
@@ -216,7 +216,7 @@ describe("a bot's page in the chat", () => {
expect(card().querySelector("[data-page-link]")?.textContent).toContain("Published for you");
await click("Only you", card());
await settle();
- expect(posts("/app/publish")).toEqual([{ rev: 0, visibility: "owner" }, { rev: 0 }]);
+ expect(posts("/app/publish")).toEqual([{ rev: 0, visibility: "owner" }, { rev: 0, visibility: "public" }]);
});
it("shows publish_page's link on the page it published", async () => {
diff --git a/src/components/app/app-api.ts b/src/components/app/app-api.ts
index df7e70962f..f1c33317d0 100644
--- a/src/components/app/app-api.ts
+++ b/src/components/app/app-api.ts
@@ -126,7 +126,7 @@ export type PagePublishOutcome = { ok: true; card: PublishedPageCard } | { ok: f
export async function publishAppPage(threadId: string, messageId: string, rev: number, visibility?: PublishedPageVisibility): Promise<PagePublishOutcome> {
try {
const body = await api<{ card: PublishedPageCard }>(`${appDocumentPath(threadId, messageId)}/publish`, {
- method: "POST", body: JSON.stringify(visibility === "owner" ? { rev, visibility } : { rev }) });
+ method: "POST", body: JSON.stringify(visibility === undefined ? { rev } : { rev, visibility }) });
return { ok: true, card: body.card };
} catch (error) {
if (!(error instanceof ApiError)) return { ok: false, error: OFFLINE_ERROR.message };