diff --git a/src/selectors.test.ts b/src/selectors.test.ts index cc815d4a..a2f4edb7 100644 --- a/src/selectors.test.ts +++ b/src/selectors.test.ts @@ -244,9 +244,9 @@ test('select user sites with project role', () => { test('select user role when site owned', () => { const user = generateUser(); const site = generateSite({ owner: user }); - const store = createStore(initState([], [user], [site])); + const store = createStore(initState([], [user], [site], user.id)); - const siteRole = selectUserRoleSite(store.getState(), site.id, user.id); + const siteRole = selectUserRoleSite(store.getState(), site.id); expect(siteRole).toStrictEqual({ kind: 'site', role: 'owner' }); }); @@ -254,8 +254,8 @@ test('select user role in project of site', () => { const user = generateUser(); const project = generateProject([generateMembership(user.id, 'viewer')]); const site = generateSite({ project }); - const store = createStore(initState([project], [user], [site])); + const store = createStore(initState([project], [user], [site], user.id)); - const siteRole = selectUserRoleSite(store.getState(), site.id, user.id); + const siteRole = selectUserRoleSite(store.getState(), site.id); expect(siteRole).toStrictEqual({ kind: 'project', role: 'viewer' }); }); diff --git a/src/selectors.ts b/src/selectors.ts index e0f18db8..59daf571 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -119,14 +119,11 @@ export type SiteUserRole = | { kind: 'site'; role: 'owner' } | { kind: 'project'; role: UserRole }; -const selectSiteId = (_state: any, siteId: string, userId: string) => [ - siteId, - userId, -]; +const selectSiteId = (_state: any, siteId: string) => siteId; export const selectUserRoleSite = createSelector( - [selectSites, selectProjects, selectSiteId], - (sites, projects, [siteId, userId]) => { + [selectSites, selectProjects, selectSiteId, selectCurrentUserID], + (sites, projects, siteId, userId) => { const site = sites[siteId]; if (!site) { return null;