fix: share persistence + clipboard fallback + auto-save
FlowDeck CI / test (push) Failing after 4s
FlowDeck CI / docker (push) Has been skipped

- DB: pages.share_mode (private/invited/anyone) + published (bool)
- API: POST /board/api/share/{id} saves share settings to DB
- view_page: passes page_share_mode + page_published to template
- page_editor: inits share state from server, auto-saves on change
- Clipboard: fallback to textarea for HTTP (navigator.clipboard blocked)
- Toast: showToast() with proper timeout clearing
This commit is contained in:
2026-07-10 12:03:32 -04:00
parent c75cdab134
commit 6033a0b1e4
3 changed files with 53 additions and 9 deletions
+21 -1
View File
@@ -383,6 +383,24 @@ async def remove_favorite(request: Request, page_id: int):
conn.commit()
return {"status": "removed", "page_id": page_id}
# ═══════════ Share API ═══════════
@router.post("/api/share/{page_id:int}")
async def update_share(request: Request, page_id: int):
"""Save share settings for a page."""
import json
body = await request.json()
mode = body.get("mode", "private")
published = body.get("published", False)
with get_conn() as conn:
conn.execute(
"UPDATE pages SET share_mode=?, published=? WHERE id=?",
(mode, 1 if published else 0, page_id),
)
conn.commit()
return {"status": "ok", "share_mode": mode, "published": published}
# ═══════════ Trash (must be before /{owner}/{repo} catch-all) ═══════════
@router.get("/api/trash")
@@ -732,7 +750,9 @@ async def view_page(request: Request, page_id: int):
fav = conn.execute(
"SELECT id FROM favorites WHERE user_id=? AND page_id=?", (uid, page_id)
).fetchone()
ctx = {**sidebar, "page": page, "page_favorited": fav is not None}
ctx = {**sidebar, "page": page, "page_favorited": fav is not None,
"page_share_mode": page.get("share_mode", "private"),
"page_published": bool(page.get("published", 0))}
template = env.get_template("page_editor.html")
return template.render(**ctx)