From cbd5a98cd3d1eea438739758316a48817a6a8ed5 Mon Sep 17 00:00:00 2001
From: Davide Scaini
Date: Fri, 10 Apr 2026 23:16:38 +0200
Subject: [PATCH] - merge.py: keep private activities in
_merged/index.json instead of stripping them; privacy filtering is
now done client-side - ActivityFeed: detect logged-in user via
bincio:me event; show private activities only when viewing your own
profile; private cards get a lock badge
---
bincio/render/merge.py | 5 ++--
site/src/components/ActivityFeed.svelte | 33 +++++++++++++++++++++----
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/bincio/render/merge.py b/bincio/render/merge.py
index 8064776..c90cb35 100644
--- a/bincio/render/merge.py
+++ b/bincio/render/merge.py
@@ -152,7 +152,6 @@ def merge_one(data_dir: Path, activity_id: str) -> None:
s = _apply_sidecar_summary(s, fm)
activities.append(s)
- activities = [a for a in activities if a.get("privacy") != "private"]
activities.sort(key=lambda a: a.get("started_at", ""), reverse=True)
activities.sort(key=lambda a: 0 if a.get("custom", {}).get("highlight") else 1)
@@ -262,9 +261,9 @@ def merge_all(data_dir: Path) -> int:
activities.append(s)
# Drop private activities from the published feed
- activities = [a for a in activities if a.get("privacy") != "private"]
-
# Sort: newest first, then bring highlighted activities to the top
+ # Private activities are kept in the index so the owner can see them;
+ # the feed UI filters them out for non-owners client-side.
activities.sort(key=lambda a: a.get("started_at", ""), reverse=True)
activities.sort(key=lambda a: 0 if a.get("custom", {}).get("highlight") else 1)
diff --git a/site/src/components/ActivityFeed.svelte b/site/src/components/ActivityFeed.svelte
index ffc330e..4d6291d 100644
--- a/site/src/components/ActivityFeed.svelte
+++ b/site/src/components/ActivityFeed.svelte
@@ -43,8 +43,20 @@
let loading = true;
let error = '';
let mounted = false;
+ /** Logged-in handle — resolved async via bincio:me event. */
+ let me: string = '';
- $: filtered = sport === 'all' ? all : all.filter(a => a.sport === sport);
+ // Show private activities only to their owner.
+ // On a profile page (filterHandle set): show private if me === filterHandle.
+ // On the global feed: show private only for the logged-in user's own activities.
+ $: isOwner = filterHandle !== '' && me === filterHandle;
+ $: withPrivacy = all.filter(a => {
+ if (a.privacy === 'private') {
+ return filterHandle ? isOwner : (me !== '' && (a as any).handle === me);
+ }
+ return true;
+ });
+ $: filtered = sport === 'all' ? withPrivacy : withPrivacy.filter(a => a.sport === sport);
$: visible = filtered.slice(0, shown);
$: hasMore = shown < filtered.length;
@@ -60,18 +72,26 @@
onMount(async () => {
sport = (new URLSearchParams(window.location.search).get('sport') as Sport | 'all') ?? 'all';
mounted = true;
+
+ // Resolve the logged-in handle so we can show the owner their private activities.
+ if ((window as any).__bincioMe !== undefined) {
+ me = (window as any).__bincioMe;
+ } else {
+ window.addEventListener('bincio:me', (e: Event) => { me = (e as CustomEvent).detail; }, { once: true });
+ }
+
try {
const indexUrl = profileIndexUrl
? `${base}data/${profileIndexUrl}`
: `${base}data/index.json`;
const index = await loadIndex(base, indexUrl);
- let activities = index.activities.filter(a => a.privacy !== 'private');
+ let activities = index.activities;
// filterHandle only applies when loading the root manifest (multi-user feed).
// When profileIndexUrl is set we already loaded the right user's shard directly —
// activities from a direct shard fetch have no handle tag, so the filter would
// remove everything.
if (filterHandle && !profileIndexUrl) {
- activities = activities.filter(a => a.handle === filterHandle);
+ activities = activities.filter(a => (a as any).handle === filterHandle);
}
all = activities;
} catch (e: any) {
@@ -140,10 +160,13 @@
>@{a.handle}{/if}
-
+
+ {#if a.privacy === 'private'}
+ 🔒
+ {/if}
{a.title}