Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Add util for link static clicks (#5683)

* Add util for link static clicks

* Format

* Update copy

authored by

Eric Bailey and committed by
GitHub
0b4dc64c a445489b

+26 -21
+19
src/components/Link.tsx
··· 330 330 } 331 331 332 332 /** 333 + * Utility to create a static `onPress` handler for a `Link` that would otherwise link to a URI 334 + * 335 + * Example: 336 + * `<Link {...createStaticClick(e => {...})} />` 337 + */ 338 + export function createStaticClick( 339 + onPressHandler: Exclude<BaseLinkProps['onPress'], undefined>, 340 + ): Pick<BaseLinkProps, 'to' | 'onPress'> { 341 + return { 342 + to: '#', 343 + onPress(e: GestureResponderEvent) { 344 + e.preventDefault() 345 + onPressHandler(e) 346 + return false 347 + }, 348 + } 349 + } 350 + 351 + /** 333 352 * A Pressable that uses useLink to handle navigation. It is unstyled, so can be used in cases where the Button styles 334 353 * in Link are not desired. 335 354 * @param displayText
+7 -21
src/components/TagMenu/index.tsx
··· 4 4 import {useLingui} from '@lingui/react' 5 5 import {useNavigation} from '@react-navigation/native' 6 6 7 - import {makeSearchLink} from '#/lib/routes/links' 8 7 import {NavigationProp} from '#/lib/routes/types' 9 8 import {isInvalidHandle} from '#/lib/strings/handles' 10 9 import { ··· 19 18 import {MagnifyingGlass2_Stroke2_Corner0_Rounded as Search} from '#/components/icons/MagnifyingGlass2' 20 19 import {Mute_Stroke2_Corner0_Rounded as Mute} from '#/components/icons/Mute' 21 20 import {Person_Stroke2_Corner0_Rounded as Person} from '#/components/icons/Person' 22 - import {Link} from '#/components/Link' 21 + import {createStaticClick, Link} from '#/components/Link' 23 22 import {Loader} from '#/components/Loader' 24 23 import {Text} from '#/components/Typography' 25 24 ··· 101 100 t.atoms.bg_contrast_25, 102 101 ]}> 103 102 <Link 104 - label={_(msg`Search for all posts with tag ${displayTag}`)} 105 - to={makeSearchLink({query: displayTag})} 106 - onPress={e => { 107 - e.preventDefault() 108 - 103 + label={_(msg`View all posts with tag ${displayTag}`)} 104 + {...createStaticClick(() => { 109 105 control.close(() => { 110 106 navigation.push('Hashtag', { 111 107 tag: encodeURIComponent(tag), 112 108 }) 113 109 }) 114 - 115 - return false 116 - }}> 110 + })}> 117 111 <View 118 112 style={[ 119 113 a.w_full, ··· 152 146 153 147 <Link 154 148 label={_( 155 - msg`Search for all posts by @${authorHandle} with tag ${displayTag}`, 149 + msg`View all posts by @${authorHandle} with tag ${displayTag}`, 156 150 )} 157 - to={makeSearchLink({ 158 - query: displayTag, 159 - from: authorHandle, 160 - })} 161 - onPress={e => { 162 - e.preventDefault() 163 - 151 + {...createStaticClick(() => { 164 152 control.close(() => { 165 153 navigation.push('Hashtag', { 166 154 tag: encodeURIComponent(tag), 167 155 author: authorHandle, 168 156 }) 169 157 }) 170 - 171 - return false 172 - }}> 158 + })}> 173 159 <View 174 160 style={[ 175 161 a.w_full,