wobsoriano / vue-clerk

Unofficial Vue + Clerk integration.
https://vue-clerk.com
MIT License
108 stars 8 forks source link

watcher on useOrganization fires several times #48

Open CptJJ opened 1 week ago

CptJJ commented 1 week ago

when watching the ref inside the useOrganization composable, or the valie.id directly, the ord switcher will cause the watcher to fire off several times. It seems as if the org id gets set correctly -> set as null -> set correctly very quickly:

image
const { organization, isLoaded } = useOrganization();
watch(organization, (newValue, oldValue) => {
  console.log(
    "newValue",
    newValue,
    "oldValue",
    oldValue,
    "isLoaded",
    isLoaded.value
  );
});

isLoaded goes to false as the org changes back to null

CptJJ commented 1 week ago

Also maybe related and helpful, the org switching modal seems to jump to the upper left of the screen for couple milliseconds when switching orgs.

wobsoriano commented 1 week ago

The useOrganization composable definitely needs some love. I'll look into this.

The way I test it is I also have a basic React app with the same hook and check if I will get the same output when I log the organization changes.

FYI useOrganization composable is incomplete, it does not have the invitations, membershipRequests, etc properties returned. We still need to think of a good pagination solution.

CptJJ commented 1 week ago

Thank you @wobsoriano !

My usecase is pretty bare bones, and I just needed to be able to request the memberships which seems to be working fine with useOrganization().organization.value.getMemberships(), I just wrapped this in vue-query to dedupe for now!

CptJJ commented 1 week ago

The afer-switch-organization-url seems to not be firing, which is another thing I would find really useful, currently working around with watchers on the organization ref