Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Better handling of blocks in `KnownFollowers` (#4563)

* Better handle nested conditionals, use renderable items to determine UI

* Better translate

* Fix translation and fix missing case in the process

* Clarify naming

* Add safeguard

* Remove unneeded msg

---------

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>

authored by

Eric Bailey
Dan Abramov
and committed by
GitHub
c92ef2fe 32b40631

+49 -18
+49 -18
src/components/KnownFollowers.tsx
··· 100 100 moderation, 101 101 } 102 102 }) 103 - const count = cachedKnownFollowers.count 103 + 104 + // Does not have blocks applied. Always >= slices.length 105 + const serverCount = cachedKnownFollowers.count 106 + 107 + /* 108 + * We check above too, but here for clarity and a reminder to _check for 109 + * valid indices_ 110 + */ 111 + if (slice.length === 0) return null 104 112 105 113 return ( 106 114 <Link ··· 164 172 }, 165 173 ]} 166 174 numberOfLines={2}> 167 - {count > 2 ? ( 168 - <Trans> 169 - Followed by{' '} 170 - <Text key={slice[0].profile.did} style={textStyle}> 171 - {slice[0].profile.displayName} 172 - </Text> 173 - ,{' '} 174 - <Text key={slice[1].profile.did} style={textStyle}> 175 - {slice[1].profile.displayName} 176 - </Text> 177 - , and{' '} 178 - <Plural value={count - 2} one="# other" other="# others" /> 179 - </Trans> 180 - ) : count === 2 ? ( 175 + {slice.length >= 2 ? ( 176 + // 2-n followers, including blocks 177 + serverCount > 2 ? ( 178 + <Trans> 179 + Followed by{' '} 180 + <Text key={slice[0].profile.did} style={textStyle}> 181 + {slice[0].profile.displayName} 182 + </Text> 183 + ,{' '} 184 + <Text key={slice[1].profile.did} style={textStyle}> 185 + {slice[1].profile.displayName} 186 + </Text> 187 + , and{' '} 188 + <Plural 189 + value={serverCount - 2} 190 + one="# other" 191 + other="# others" 192 + /> 193 + </Trans> 194 + ) : ( 195 + // only 2 196 + <Trans> 197 + Followed by{' '} 198 + <Text key={slice[0].profile.did} style={textStyle}> 199 + {slice[0].profile.displayName} 200 + </Text>{' '} 201 + and{' '} 202 + <Text key={slice[1].profile.did} style={textStyle}> 203 + {slice[1].profile.displayName} 204 + </Text> 205 + </Trans> 206 + ) 207 + ) : serverCount > 1 ? ( 208 + // 1-n followers, including blocks 181 209 <Trans> 182 210 Followed by{' '} 183 211 <Text key={slice[0].profile.did} style={textStyle}> 184 212 {slice[0].profile.displayName} 185 213 </Text>{' '} 186 214 and{' '} 187 - <Text key={slice[1].profile.did} style={textStyle}> 188 - {slice[1].profile.displayName} 189 - </Text> 215 + <Plural 216 + value={serverCount - 1} 217 + one="# other" 218 + other="# others" 219 + /> 190 220 </Trans> 191 221 ) : ( 222 + // only 1 192 223 <Trans> 193 224 Followed by{' '} 194 225 <Text key={slice[0].profile.did} style={textStyle}>