fix: show total activity count in global feed counter

The counter now shows "50 of 16398 activities" using the total from
feed.json, matching the previous behaviour where all activities were
loaded upfront.
This commit is contained in:
Davide Scaini
2026-04-20 17:12:50 +02:00
parent 104328bc50
commit 6491e4fd8c
2 changed files with 10 additions and 2 deletions
+7
View File
@@ -48,6 +48,8 @@
/** Remaining combined-feed pages (multi-user global feed). */ /** Remaining combined-feed pages (multi-user global feed). */
let feedNextPage = 0; let feedNextPage = 0;
let feedTotalPages = 0; let feedTotalPages = 0;
/** Grand total from feed.json — shows instance-wide count even before all pages are loaded. */
let totalActivities = 0;
/** Logged-in handle — resolved async via bincio:me event. */ /** Logged-in handle — resolved async via bincio:me event. */
let me: string = ''; let me: string = '';
@@ -123,6 +125,7 @@
const combined = await loadCombinedFeed(base); const combined = await loadCombinedFeed(base);
if (combined) { if (combined) {
all = combined.activities; all = combined.activities;
totalActivities = combined.totalActivities;
feedTotalPages = combined.remainingPages + 1; feedTotalPages = combined.remainingPages + 1;
feedNextPage = combined.remainingPages > 0 ? 2 : 0; feedNextPage = combined.remainingPages > 0 ? 2 : 0;
loading = false; loading = false;
@@ -175,7 +178,11 @@
{/each} {/each}
{#if all.length > 0} {#if all.length > 0}
<span class="ml-auto text-sm text-zinc-500 self-center"> <span class="ml-auto text-sm text-zinc-500 self-center">
{#if totalActivities > filtered.length}
{filtered.length} of {totalActivities} activities
{:else}
{filtered.length} {filtered.length === 1 ? 'activity' : 'activities'} {filtered.length} {filtered.length === 1 ? 'activity' : 'activities'}
{/if}
</span> </span>
{/if} {/if}
</div> </div>
+2 -1
View File
@@ -269,12 +269,13 @@ interface FeedPage {
*/ */
export async function loadCombinedFeed( export async function loadCombinedFeed(
baseUrl: string, baseUrl: string,
): Promise<{ activities: ActivitySummary[]; remainingPages: number } | null> { ): Promise<{ activities: ActivitySummary[]; remainingPages: number; totalActivities: number } | null> {
try { try {
const feed = await fetchJSON<FeedPage>(`${baseUrl}data/feed.json`); const feed = await fetchJSON<FeedPage>(`${baseUrl}data/feed.json`);
return { return {
activities: feed.activities ?? [], activities: feed.activities ?? [],
remainingPages: (feed.total_pages ?? 1) - 1, remainingPages: (feed.total_pages ?? 1) - 1,
totalActivities: feed.total_activities ?? 0,
}; };
} catch { } catch {
return null; return null;