Skip to content

Commit ec41bb7

Browse files
authored
fix(clerk-js): Only render active sessions in devices section (#3497)
1 parent 4302405 commit ec41bb7

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Only render active sessions in the active devices section. Fixes the bug where a device with no information would render upon revoking.

packages/clerk-js/src/ui/components/UserProfile/ActiveDevicesSection.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ export const ActiveDevicesSection = () => {
2828
{isLoading ? (
2929
<FullHeightLoader />
3030
) : (
31-
sessions?.sort(currentSessionFirst(session!.id)).map(sa => (
32-
<DeviceItem
33-
key={sa.id}
34-
session={sa}
35-
/>
36-
))
31+
sessions?.sort(currentSessionFirst(session!.id)).map(sa => {
32+
if (sa.status !== 'active') {
33+
return null;
34+
}
35+
return (
36+
<DeviceItem
37+
key={sa.id}
38+
session={sa}
39+
/>
40+
);
41+
})
3742
)}
3843
</ProfileSection.ItemList>
3944
</ProfileSection.Root>

packages/clerk-js/src/ui/hooks/useFetch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export const useFetch = <K, T>(
7878

7979
useEffect(() => {
8080
const fetcherMissing = !fetcherRef.current;
81-
const isCacheStale = Date.now() - (getCache()?.cachedAt || 0) < staleTime;
81+
const isCacheStale = Date.now() - (getCache()?.cachedAt || 0) >= staleTime;
8282
const isRequestOnGoing = getCache()?.isValidating;
8383

84-
if (fetcherMissing || isCacheStale || isRequestOnGoing) {
84+
if (fetcherMissing || !isCacheStale || isRequestOnGoing) {
8585
return;
8686
}
8787

0 commit comments

Comments
 (0)