Skip to content

Commit 5422b61

Browse files
refactor(mobile): useEnvironmentScope reads through useEnvironmentScopeAccess
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 393988e commit 5422b61

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

‎apps/mobile/src/state/session.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export function useEnvironmentScopeAccess(
4141
environmentId: EnvironmentId | null,
4242
scope: AuthEnvironmentScope,
4343
): EnvironmentScopeAccess {
44+
// Select the access: every revalidation emits a new result, and most consumers are list rows.
4445
return useAtomValue(
4546
environmentId === null
4647
? EMPTY_SESSION_STATE_ATOM
@@ -53,13 +54,7 @@ export function useEnvironmentScope(
5354
environmentId: EnvironmentId | null,
5455
scope: AuthEnvironmentScope,
5556
): boolean {
56-
// Select the grant: every revalidation emits a new result, and most consumers are list rows.
57-
return useAtomValue(
58-
environmentId === null
59-
? EMPTY_SESSION_STATE_ATOM
60-
: environmentSession.sessionStateAtom(environmentId),
61-
(result) => sessionHasScope(result, scope),
62-
);
57+
return useEnvironmentScopeAccess(environmentId, scope) === "granted";
6358
}
6459

6560
export function useEnvironmentsWithScope(

0 commit comments

Comments
 (0)