Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Prevent sparse arrays in snapToOffsets (#9329)

* prevent sparse arrays in snapToOffsets

* wait, sparse arrays don't work like that

* more readable check even if it's technically useless

* make the second check actually work

authored by

Samuel Newman and committed by
GitHub
78e20c42 d8e7e65a

+7 -2
+7 -2
src/components/InterestTabs.tsx
··· 83 83 function handleTabLayout(index: number, x: number, width: number) { 84 84 if (!tabOffsets.length) { 85 85 pendingTabOffsets.current[index] = {x, width} 86 - if (pendingTabOffsets.current.length === interests.length) { 86 + // not only do we check if the length is equal to the number of interests, 87 + // but we also need to ensure that the array isn't sparse. `.filter()` 88 + // removes any empty slots from the array 89 + if ( 90 + pendingTabOffsets.current.filter(o => !!o).length === interests.length 91 + ) { 87 92 setTabOffsets(pendingTabOffsets.current) 88 93 } 89 94 } ··· 205 210 showsHorizontalScrollIndicator={false} 206 211 decelerationRate="fast" 207 212 snapToOffsets={ 208 - tabOffsets.length === interests.length 213 + tabOffsets.filter(o => !!o).length === interests.length 209 214 ? tabOffsets.map(o => o.x - tokens.space.xl) 210 215 : undefined 211 216 }