mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

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

Always limit Following replies to the people you follow (#4868)

* Limit feed replies to people you follow

* Remove dead code

authored by danabra.mov and committed by

GitHub 7f292abf f056cb64

+8 -126
+2 -12
src/lib/api/feed-manip.ts
··· 299 299 return slices 300 300 } 301 301 302 - static thresholdRepliesOnly({ 303 - userDid, 304 - minLikes, 305 - followedOnly, 306 - }: { 307 - userDid: string 308 - minLikes: number 309 - followedOnly: boolean 310 - }) { 302 + static followedRepliesOnly({userDid}: {userDid: string}) { 311 303 return ( 312 304 tuner: FeedTuner, 313 305 slices: FeedViewPostsSlice[], ··· 322 314 if (slice.isRepost) { 323 315 continue 324 316 } 325 - if (slice.likeCount < minLikes) { 326 - slices.splice(i, 1) 327 - } else if (followedOnly && !slice.isFollowingAllAuthors(userDid)) { 317 + if (!slice.isFollowingAllAuthors(userDid)) { 328 318 slices.splice(i, 1) 329 319 } 330 320 }
+2 -7
src/state/preferences/feed-tuners.tsx
··· 38 38 feedTuners.push(FeedTuner.removeReplies) 39 39 } else { 40 40 feedTuners.push( 41 - FeedTuner.thresholdRepliesOnly({ 41 + FeedTuner.followedRepliesOnly({ 42 42 userDid: currentAccount?.did || '', 43 - minLikes: preferences?.feedViewPrefs.hideRepliesByLikeCount || 0, 44 - followedOnly: 45 - !!preferences?.feedViewPrefs.hideRepliesByUnfollowed, 46 43 }), 47 44 ) 48 45 } ··· 66 63 feedTuners.push(FeedTuner.removeReplies) 67 64 } else { 68 65 feedTuners.push( 69 - FeedTuner.thresholdRepliesOnly({ 66 + FeedTuner.followedRepliesOnly({ 70 67 userDid: currentAccount?.did || '', 71 - minLikes: preferences?.feedViewPrefs.hideRepliesByLikeCount || 0, 72 - followedOnly: !!preferences?.feedViewPrefs.hideRepliesByUnfollowed, 73 68 }), 74 69 ) 75 70 }
+2 -2
src/state/queries/preferences/const.ts
··· 7 7 export const DEFAULT_HOME_FEED_PREFS: UsePreferencesQueryResponse['feedViewPrefs'] = 8 8 { 9 9 hideReplies: false, 10 - hideRepliesByUnfollowed: true, 11 - hideRepliesByLikeCount: 0, 10 + hideRepliesByUnfollowed: true, // Legacy, ignored 11 + hideRepliesByLikeCount: 0, // Legacy, ignored 12 12 hideReposts: false, 13 13 hideQuotePosts: false, 14 14 lab_mergeFeedEnabled: false, // experimental
+2 -105
src/view/screens/PreferencesFollowingFeed.tsx
··· 1 - import React, {useState} from 'react' 1 + import React from 'react' 2 2 import {StyleSheet, View} from 'react-native' 3 3 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 4 - import {msg, Plural, Trans} from '@lingui/macro' 4 + import {msg, Trans} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 - import {Slider} from '@miblanchard/react-native-slider' 7 - import debounce from 'lodash.debounce' 8 6 9 7 import {usePalette} from '#/lib/hooks/usePalette' 10 8 import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' 11 9 import {CommonNavigatorParams, NativeStackScreenProps} from '#/lib/routes/types' 12 10 import {colors, s} from '#/lib/styles' 13 - import {isWeb} from '#/platform/detection' 14 11 import { 15 12 usePreferencesQuery, 16 13 useSetFeedViewPreferencesMutation, ··· 21 18 import {ScrollView} from '#/view/com/util/Views' 22 19 import {atoms as a} from '#/alf' 23 20 24 - function RepliesThresholdInput({ 25 - enabled, 26 - initialValue, 27 - }: { 28 - enabled: boolean 29 - initialValue: number 30 - }) { 31 - const pal = usePalette('default') 32 - const [value, setValue] = useState(initialValue) 33 - const {mutate: setFeedViewPref} = useSetFeedViewPreferencesMutation() 34 - const preValue = React.useRef(initialValue) 35 - const save = React.useMemo( 36 - () => 37 - debounce( 38 - threshold => 39 - setFeedViewPref({ 40 - hideRepliesByLikeCount: threshold, 41 - }), 42 - 500, 43 - ), // debouce for 500ms 44 - [setFeedViewPref], 45 - ) 46 - 47 - return ( 48 - <View style={[!enabled && styles.dimmed]}> 49 - <Slider 50 - value={value} 51 - onValueChange={(v: number | number[]) => { 52 - let threshold = Array.isArray(v) ? v[0] : v 53 - if (threshold > preValue.current) threshold = Math.floor(threshold) 54 - else threshold = Math.ceil(threshold) 55 - 56 - preValue.current = threshold 57 - 58 - setValue(threshold) 59 - save(threshold) 60 - }} 61 - minimumValue={0} 62 - maximumValue={25} 63 - containerStyle={isWeb ? undefined : s.flex1} 64 - disabled={!enabled} 65 - thumbTintColor={colors.blue3} 66 - /> 67 - <Text type="xs" style={pal.text}> 68 - <Plural 69 - value={value} 70 - _0="Show all replies" 71 - one="Show replies with at least # like" 72 - other="Show replies with at least # likes" 73 - /> 74 - </Text> 75 - </View> 76 - ) 77 - } 78 - 79 21 type Props = NativeStackScreenProps< 80 22 CommonNavigatorParams, 81 23 'PreferencesFollowingFeed' ··· 137 79 } 138 80 /> 139 81 </View> 140 - <View 141 - style={[pal.viewLight, styles.card, !showReplies && styles.dimmed]}> 142 - <Text type="title-sm" style={[pal.text, s.pb5]}> 143 - <Trans>Reply Filters</Trans> 144 - </Text> 145 - <Text style={[pal.text, s.pb10]}> 146 - <Trans> 147 - Enable this setting to only see replies between people you 148 - follow. 149 - </Trans> 150 - </Text> 151 - <ToggleButton 152 - type="default-light" 153 - label={_(msg`Followed users only`)} 154 - isSelected={Boolean( 155 - variables?.hideRepliesByUnfollowed ?? 156 - preferences?.feedViewPrefs?.hideRepliesByUnfollowed, 157 - )} 158 - onPress={ 159 - showReplies 160 - ? () => 161 - setFeedViewPref({ 162 - hideRepliesByUnfollowed: !( 163 - variables?.hideRepliesByUnfollowed ?? 164 - preferences?.feedViewPrefs?.hideRepliesByUnfollowed 165 - ), 166 - }) 167 - : undefined 168 - } 169 - style={[s.mb10]} 170 - /> 171 - <Text style={[pal.text]}> 172 - <Trans> 173 - Adjust the number of likes a reply must have to be shown in your 174 - feed. 175 - </Trans> 176 - </Text> 177 - {preferences && ( 178 - <RepliesThresholdInput 179 - enabled={showReplies} 180 - initialValue={preferences.feedViewPrefs.hideRepliesByLikeCount} 181 - /> 182 - )} 183 - </View> 184 - 185 82 <View style={[pal.viewLight, styles.card]}> 186 83 <Text type="title-sm" style={[pal.text, s.pb5]}> 187 84 <Trans>Show Reposts</Trans>