databuddy-analytics / databuddy-analytics/Databuddy

Flag list not refreshed after status toggle/archive when flag.websiteId doesn't match the query key

Open Beginner friendly
#664 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
216
Avg merge
14h 53m
Merged PRs (30d)
154

Description

Bug

In apps/dashboard/app/(main)/websites/[id]/flags/_components/flags-list.tsx, both StatusToggle and FlagActions invalidate the flag list query after a successful mutation using:

queryClient.invalidateQueries({
    queryKey: orpc.flags.list.key({
        input: { websiteId: flag.websiteId ?? "" },
    }),
});

But the page's list query is keyed with the route param (page.tsx):

useQuery({
    ...orpc.flags.list.queryOptions({ input: { websiteId } }), // websiteId = route param
});

oRPC / React Query invalidation matches keys element-wise. For any flag whose websiteId is null, the invalidation key carries websiteId: "" and never matches the cached entry — so after toggling or archiving a flag, the list keeps showing stale status until a manual page refresh.

Current reachability

Today this is latent: the flags page only lists website-scoped flags (the RPC list filter is eq(flags.websiteId, input.websiteId)), so every row has a matching websiteId. It becomes live as soon as:

  • org-scoped flags are rendered in this component, or
  • the list schema starts returning hybrid rows.
Suggested fix

Thread the real websiteId from the route into FlagsListFlagRowStatusToggle/FlagActions and use it for invalidation instead of flag.websiteId ?? "".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/dashboard/app/(main)/websites/[id]/flags/_components/flags-list.tsx and compare the mutation invalidation keys with the websiteId used by page.tsx. Trace the route websiteId through FlagsList, FlagRow, StatusToggle, and FlagActions, then verify that toggling or archiving refreshes the visible list without a manual reload.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.