about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-08-04 09:26:09 -0700
committerGitHub <noreply@github.com>2023-08-04 09:26:09 -0700
commitc4459ec4e8265168d39ba8b8b7192ae8e1c94430 (patch)
tree95be6a48e90c3002877d9a15db1dbd2a99e9481f /src
parentb154d3ea21bcca48594aa397420b0f6718dbf7f3 (diff)
downloadvoidsky-c4459ec4e8265168d39ba8b8b7192ae8e1c94430.tar.zst
Simplify the after-post logic to avoid a UI bug (#1105)
Diffstat (limited to 'src')
-rw-r--r--src/state/models/feeds/posts.ts24
-rw-r--r--src/view/com/composer/Composer.tsx5
2 files changed, 7 insertions, 22 deletions
diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts
index 94d7228ed..e5d2eba07 100644
--- a/src/state/models/feeds/posts.ts
+++ b/src/state/models/feeds/posts.ts
@@ -8,7 +8,7 @@ import AwaitLock from 'await-lock'
 import {bundleAsync} from 'lib/async/bundle'
 import {RootStoreModel} from '../root-store'
 import {cleanError} from 'lib/strings/errors'
-import {FeedTuner, FeedViewPostsSlice} from 'lib/api/feed-manip'
+import {FeedTuner} from 'lib/api/feed-manip'
 import {PostsFeedSliceModel} from './posts-slice'
 import {track} from 'lib/analytics/analytics'
 
@@ -286,27 +286,13 @@ export class PostsFeedModel {
   }
 
   /**
-   * Fetches the given post and adds it to the top
-   * Used by the composer to add their new posts
+   * Updates the UI after the user has created a post
    */
-  async addPostToTop(uri: string) {
+  onPostCreated() {
     if (!this.slices.length) {
       return this.refresh()
-    }
-    try {
-      const res = await this.rootStore.agent.app.bsky.feed.getPosts({
-        uris: [uri],
-      })
-      const toPrepend = new PostsFeedSliceModel(
-        this.rootStore,
-        uri,
-        new FeedViewPostsSlice(res.data.posts.map(post => ({post}))),
-      )
-      runInAction(() => {
-        this.slices = [toPrepend].concat(this.slices)
-      })
-    } catch (e) {
-      this.rootStore.log.error('Failed to load post to prepend', {e})
+    } else {
+      this.setHasNewLatest(true)
     }
   }
 
diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx
index 0fae996ff..9fdf0bc6f 100644
--- a/src/view/com/composer/Composer.tsx
+++ b/src/view/com/composer/Composer.tsx
@@ -163,9 +163,8 @@ export const ComposePost = observer(function ComposePost({
 
       setIsProcessing(true)
 
-      let createdPost
       try {
-        createdPost = await apilib.post(store, {
+        await apilib.post(store, {
           rawText: rt.text,
           replyTo: replyTo?.uri,
           images: gallery.images,
@@ -193,7 +192,7 @@ export const ComposePost = observer(function ComposePost({
         if (replyTo && replyTo.uri) track('Post:Reply')
       }
       if (!replyTo) {
-        await store.me.mainFeed.addPostToTop(createdPost.uri)
+        store.me.mainFeed.onPostCreated()
       }
       onPost?.()
       onClose()