Skip to content

Manual "Refresh" button updates the database but not the visible dashboard #53

Description

@2ndtlmining

Labels: bug, ui

Problem

The footer's "Refresh [F5]" button (src/lib/components/Footer.svelte) correctly triggers a full live re-fetch on the backend:

async function handleRefresh() {
    ...
    const response = await fetch(`${API_URL}/api/admin/test-services`, { method: 'POST' });
    ...
    await fetchFooterStats(); // only refreshes footer's own tx count / sync status
}

The backend route (POST /api/admin/test-services in src/server.js) does run testAllServices(), fetchRevenueStats(), and fetchCarouselData() in parallel and writes fresh values to the database immediately. But handleRefresh() only calls fetchFooterStats() afterward — it never tells the main page to reload its metrics.

The gaming/crypto/cloud/WordPress cards live in src/routes/+page.svelte, which polls independently on its own 5-minute timer:

interval = setInterval(async () => {
    await fetchMetrics();
    ...
}, 300000);

Result: clicking Refresh silently updates the database with current numbers, but the visible cards don't change until the next 5-minute poll or a full page reload — making the button appear to do nothing.

Solution

Wire the Footer's refresh action to the page-level metrics fetch, e.g. pass a callback prop from +page.svelte into <Footer>:

<!-- +page.svelte -->
<Footer onRefreshComplete={fetchMetrics} />
// Footer.svelte
export let onRefreshComplete = () => {};

async function handleRefresh() {
    ...
    await fetchFooterStats();
    await onRefreshComplete?.();
}

A shared Svelte store is a reasonable alternative if more components need to react to the same refresh event later.

Files: src/lib/components/Footer.svelte, src/routes/+page.svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions