Skip to content

fix(clerk-js): Update cache key for roles when organization changes - #3624

Merged
panteliselef merged 2 commits into
mainfrom
elef/sdk-1822-should-refetch-roles-when-switching-organization
Jun 26, 2024
Merged

fix(clerk-js): Update cache key for roles when organization changes#3624
panteliselef merged 2 commits into
mainfrom
elef/sdk-1822-should-refetch-roles-when-switching-organization

Conversation

@panteliselef

Copy link
Copy Markdown
Contributor

Description

Fixes SDK-1822

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@panteliselef panteliselef self-assigned this Jun 26, 2024
@changeset-bot

changeset-bot Bot commented Jun 26, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8425c80

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@panteliselef
panteliselef merged commit 3b2d7d9 into main Jun 26, 2024
@panteliselef
panteliselef deleted the elef/sdk-1822-should-refetch-roles-when-switching-organization branch June 26, 2024 12:53
f.withOrganizations();
f.withUser({ email_addresses: ['test@clerk.com'], organization_memberships: ['Org1', 'Org2'] });
});
fixtures.clerk.organization?.getRoles.mockRejectedValue(null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@panteliselef Based on the ticket i think that we need to add a test to verify that different organization roles are displayed / fetched when the organization is switched.
The updated test does not seem to be related to that scenario.

const { data, isLoading } = useFetch(enabled && !!organization?.id ? organization?.getRoles : undefined, {
...getRolesParams,
orgId: organization?.id,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 Do we populate the organization instance for personal account? If not i would expect to use enabled && !!organization instead. Eg:

  const { data, isLoading } = useFetch(enabled && !!organization ? organization?.getRoles : undefined, {
    ...getRolesParams,
    orgId: organization?.id,
  });

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants