Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Merge branch 'mary-ext-feat/search-from-me' into main

+31 -2
+24
src/lib/strings/helpers.ts
··· 37 37 if (!str) return 0 38 38 return str.match(/\n/g)?.length ?? 0 39 39 } 40 + 41 + // Augments search query with additional syntax like `from:me` 42 + export function augmentSearchQuery(query: string, {did}: {did?: string}) { 43 + // Don't do anything if there's no DID 44 + if (!did) { 45 + return query 46 + } 47 + 48 + // We don't want to replace substrings that are being "quoted" because those 49 + // are exact string matches, so what we'll do here is to split them apart 50 + 51 + // Even-indexed strings are unquoted, odd-indexed strings are quoted 52 + const splits = query.split(/("(?:[^"\\]|\\.)*")/g) 53 + 54 + return splits 55 + .map((str, idx) => { 56 + if (idx % 2 === 0) { 57 + return str.replaceAll(/(^|\s)from:me(\s|$)/g, `$1${did}$2`) 58 + } 59 + 60 + return str 61 + }) 62 + .join('') 63 + }
+7 -2
src/view/screens/Search/Search.tsx
··· 52 52 import {listenSoftReset} from '#/state/events' 53 53 import {s} from '#/lib/styles' 54 54 import AsyncStorage from '@react-native-async-storage/async-storage' 55 + import {augmentSearchQuery} from '#/lib/strings/helpers' 55 56 56 57 function Loader() { 57 58 const pal = usePalette('default') ··· 318 319 const pal = usePalette('default') 319 320 const setMinimalShellMode = useSetMinimalShellMode() 320 321 const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() 321 - const {hasSession} = useSession() 322 + const {hasSession, currentAccount} = useSession() 322 323 const {isDesktop} = useWebMediaQueries() 324 + 325 + const augmentedQuery = React.useMemo(() => { 326 + return augmentSearchQuery(query || '', {did: currentAccount?.did}) 327 + }, [query, currentAccount]) 323 328 324 329 const onPageSelected = React.useCallback( 325 330 (index: number) => { ··· 343 348 )} 344 349 initialPage={0}> 345 350 <View> 346 - <SearchScreenPostResults query={query} /> 351 + <SearchScreenPostResults query={augmentedQuery} /> 347 352 </View> 348 353 <View> 349 354 <SearchScreenUserResults query={query} />