Skip to content

Commit

Permalink
[AAP-26470] Add an optional disabled property to the EdaActiveUserPro…
Browse files Browse the repository at this point in the history
…vider (#2627)
  • Loading branch information
lgalis authored Jul 2, 2024
1 parent 40e9376 commit 5e2f4ac
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion frontend/eda/common/useEdaActiveUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ export function useEdaActiveUser() {
return useContext(EdaActiveUserContext);
}

export function EdaActiveUserProvider(props: { children: ReactNode }) {
export function EdaActiveUserProvider(props: { children: ReactNode; disabled?: boolean }) {
return props?.disabled ? (
<EdaActiveUserContext.Provider value={{}}>{props.children}</EdaActiveUserContext.Provider>
) : (
<EdaActiveUserProviderInternal>{props?.children}</EdaActiveUserProviderInternal>
);
}

export function EdaActiveUserProviderInternal(props: { children: ReactNode }) {
const response = useSWR<EdaUser>(edaAPI`/users/me/`, requestGet, {
dedupingInterval: 0,
refreshInterval: 10 * 1000,
Expand Down

0 comments on commit 5e2f4ac

Please sign in to comment.