Skip to content

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

Description

@r69shabh

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 ?? "".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions