Post showing up in global feed slow

When I create a post like below method createMyImagePost and after the post being posted. When I call getGlobalFeed. Sometimes the getglobalfeed gets the post right away but some other times the post gets retrieved after waiting for minutes (ex. over 5 minutes or more). What may be the issue and how can I see updated global feed right away after post has been posted.

createMyImagePost Method


  Future<AmityPost> createMyImagePost(
    AmityImage uploadedImage,
  ) async {
    try {
      AmityPost post = await AmitySocialClient.newPostRepository()
          .createPost()
          .targetMe()
          .image([uploadedImage])
          .text('')
          .post();
      AppLogger.logInfo('createMyImagePost success: ${post.postId}');
      return post;
    } catch (exception) {
      AppLogger.logError('createMyImagePost error: ${exception.toString()}');
      rethrow;
    }
  }

getGlobalFeed Method

    _controller = PagingController(
      pageFuture: (token) => AmitySocialClient.newFeedRepository()
          .getGlobalFeed()
          .getPagingData(token: token, limit: 20),
      pageSize: 20,
    )..addListener(
        () {
          if (_controller.error == null) {
            //handle results, we suggest to clear the previous items
            //and add with the latest _controller.loadedItems
            lockedPosts.clear();
            unlockedPosts.clear();
            try {
              //? categorize the posts by comparing previous unlocked time
              for (AmityPost amityPost in _controller.loadedItems) {
                DateTime postCreatedAt = amityPost.createdAt!;
                //? if previousUnlockedTime is null then lock all photos
                if (locktimeService.previousUnlockedTime == null) {
                  lockedPosts.add(amityPost);
                }

                //? if postCreatedAt is before or equal to the previousUnlockedTime then unlock, else lock
                else if (postCreatedAt.isBefore(
                        locktimeService.previousUnlockedTime!.toUtc()) ||
                    postCreatedAt.isAtSameMomentAs(
                        locktimeService.previousUnlockedTime!.toUtc())) {
                  //* add to unlockedPosts
                  unlockedPosts.add(amityPost);
                } else {
                  //* add to lockedPosts
                  lockedPosts.add(amityPost);
                }
              }

              //? Retrieve Fam Images
              _retrieveFamImages();

              AppLogger.logInfo(
                  'Updated lockedPosts: ${lockedPosts.length} unlockedPosts: ${unlockedPosts.length}');
            } catch (exception) {
              AppLogger.logError('Error in categorizing posts: $exception');
            }
            lockedPosts.refresh();
            unlockedPosts.refresh();
            //update widgets
          } else {
            //error on pagination controller
            //update widgets
          }
        },
      );

Hello, to enhance loading time, we recommend changing your feed order to chronological. This adjustment will improve the loading time for post appearances.

f you’re interested in making this adjustment, please feel free to contact our support team at support.asc@amity.co