Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

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

Wait for AppView when posting (#4584)

authored by

dan and committed by
GitHub
5d98b4b0 51f5e6bf

+34
+34
src/view/com/composer/Composer.tsx
··· 24 24 } from 'react-native-reanimated' 25 25 import {useSafeAreaInsets} from 'react-native-safe-area-context' 26 26 import {LinearGradient} from 'expo-linear-gradient' 27 + import { 28 + AppBskyFeedDefs, 29 + AppBskyFeedGetPostThread, 30 + BskyAgent, 31 + } from '@atproto/api' 27 32 import {RichText} from '@atproto/api' 28 33 import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' 29 34 import {msg, Trans} from '@lingui/macro' 30 35 import {useLingui} from '@lingui/react' 31 36 import {observer} from 'mobx-react-lite' 32 37 38 + import {until} from '#/lib/async/until' 33 39 import { 34 40 createGIFDescription, 35 41 parseAltFromGIFDescription, ··· 299 305 langs: toPostLanguages(langPrefs.postLanguage), 300 306 }) 301 307 ).uri 308 + try { 309 + await whenAppViewReady(agent, postUri, res => { 310 + const thread = res.data.thread 311 + return AppBskyFeedDefs.isThreadViewPost(thread) 312 + }) 313 + } catch (waitErr: any) { 314 + logger.error(waitErr, { 315 + message: `Waiting for app view failed`, 316 + }) 317 + // Keep going because the post *was* published. 318 + } 302 319 } catch (e: any) { 303 320 logger.error(e, { 304 321 message: `Composer: create post failed`, ··· 754 771 755 772 // all other iPhones 756 773 return top + 10 774 + } 775 + 776 + async function whenAppViewReady( 777 + agent: BskyAgent, 778 + uri: string, 779 + fn: (res: AppBskyFeedGetPostThread.Response) => boolean, 780 + ) { 781 + await until( 782 + 5, // 5 tries 783 + 1e3, // 1s delay between tries 784 + fn, 785 + () => 786 + agent.app.bsky.feed.getPostThread({ 787 + uri, 788 + depth: 0, 789 + }), 790 + ) 757 791 } 758 792 759 793 const styles = StyleSheet.create({