Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

fix: too many re-renders when toggling experimental feed sampling option (#10114)

authored by

Paweł Fornagiel and committed by
GitHub
894e2b89 3e37696d

+14 -14
+14 -14
src/state/cache/profile-shadow.ts
··· 134 134 new Map<string, {muted: boolean; blocked: boolean}>(), 135 135 ) 136 136 137 - const [prevData, setPrevData] = useState(data) 138 - if (data !== prevData) { 139 - const newAuthors = new Set(trackedDids) 140 - let hasNew = false 141 - for (const slice of data?.flatMap(page => page.slices) ?? []) { 142 - for (const item of slice.items) { 143 - const author = item.post.author 144 - if (!newAuthors.has(author.did)) { 145 - hasNew = true 146 - newAuthors.add(author.did) 137 + useEffect(() => { 138 + setTrackedDids(prev => { 139 + const currentDids = new Set(prev) 140 + let hasNew = false 141 + for (const slice of data?.flatMap(page => page.slices) ?? []) { 142 + for (const item of slice.items) { 143 + const author = item.post.author 144 + if (!currentDids.has(author.did)) { 145 + hasNew = true 146 + currentDids.add(author.did) 147 + } 147 148 } 148 149 } 149 - } 150 - if (hasNew) setTrackedDids([...newAuthors]) 151 - setPrevData(data) 152 - } 150 + return hasNew ? [...currentDids] : prev 151 + }) 152 + }, [data]) 153 153 154 154 useEffect(() => { 155 155 const unsubs: Array<() => void> = []