# hasMore stale after dataUpdated event

**URL:** <https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268>\
**Category:** Web\
**Tags:** technical\
**Created:** [August 18, 2021, 1:00pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268 "2021-08-18T13:00:17Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.social.plus/u/matt)\
**Post date:** [August 18, 2021, 1:00pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/1 "2021-08-18T13:00:17Z")

</div>

I’m retrieving posts from a community and checking for further pages when the results are loaded using the following code.

```auto
import { FeedType, PostRepository } from '@amityco/js-sdk'

const communityId = 'XXX'

const results = PostRepository.queryCommunityPosts({
    feedType: FeedType.Published
    communityId,
})

results.on('dataUpdated', (data) => {
    console.log(results.hasMore)
    setTimeout(() => console.log(results.hasMore))
})

```

The problem is that the value of `hasMore` is always stale, and I need to work around this by wrapping the check in a `setTimeout` to get the correct value.

Given a community with two pages of results, the first load will return `false` for `hasMore` and if I call `nextPage`, the next load will return `true`.

Am I misunderstanding how to use the results? Or is this a bug?

---

<div class="post-metadata">

**Author:** ![touchaponk](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@touchaponk](https://forum.social.plus/u/touchaponk)\
**Post date:** [August 19, 2021, 4:36am UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/2 "2021-08-19T04:36:30Z")

</div>

Hi @matt - we have identified and is able to reproduce the issue. I have provide this bug to the product team and will fix it in the upcoming releases

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [September 21, 2021, 7:27am UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/3 "2021-09-21T07:27:21Z")

</div>

Hello @matt sorry for keeping you waiting, the fix version of this issue will be v4.18.0 which will be released on the 28th of September.

---

<div class="post-metadata">

**Author:** ![rdmitrij](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/rdmitrij/32/174_2.png) [@rdmitrij](https://forum.social.plus/u/rdmitrij)\
**Post date:** [January 4, 2022, 5:12pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/4 "2022-01-04T17:12:54Z")

</div>

I use `"@amityco/js-sdk": "^5.8.1"` and it still reproduced for `PostRepository.queryPosts` method.

---

<div class="post-metadata">

**Author:** ![touchaponk](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@touchaponk](https://forum.social.plus/u/touchaponk)\
**Post date:** [January 4, 2022, 5:14pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/5 "2022-01-04T17:14:52Z")

</div>

Hi @rdmitrij - can I confirm that the code is still the same as what you’ve shared a while ago?

---

<div class="post-metadata">

**Author:** ![rdmitrij](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/rdmitrij/32/174_2.png) [@rdmitrij](https://forum.social.plus/u/rdmitrij)\
**Post date:** [January 4, 2022, 5:16pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/6 "2022-01-04T17:16:40Z")

</div>

It’s not a my code snippet, but yes, code is the same.

---

<div class="post-metadata">

**Author:** ![rdmitrij](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/rdmitrij/32/174_2.png) [@rdmitrij](https://forum.social.plus/u/rdmitrij)\
**Post date:** [January 4, 2022, 5:22pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/7 "2022-01-04T17:22:24Z")

</div>

I updated the code snippet to this one and result the same.

```auto
import { PostRepository } from '@amityco/js-sdk';

const results = PostRepository.queryPosts({
    targetId: 'XXX',
    targetType: 'community',
    dataTypes: ['XXXX'],
})

results.on('dataUpdated', (data) => {
    console.log(results.hasMore); // false
    setTimeout(() => console.log(results.hasMore)); // true
});

```

---

<div class="post-metadata">

**Author:** ![touchaponk](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@touchaponk](https://forum.social.plus/u/touchaponk)\
**Post date:** [January 4, 2022, 5:28pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/8 "2022-01-04T17:28:50Z")

</div>

> [@matt](#):
>
> ```auto
> results.on('dataUpdated', (data) => {
> console.log(results.hasMore)
> setTimeout(() => console.log(results.hasMore))
> })
> 
> ```

could you please add `limit: 5` into the query json?

---

<div class="post-metadata">

**Author:** ![rdmitrij](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/rdmitrij/32/174_2.png) [@rdmitrij](https://forum.social.plus/u/rdmitrij)\
**Post date:** [January 4, 2022, 5:36pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/9 "2022-01-04T17:36:49Z")

</div>

Yes. Result is the same. I got `false` and then `true`

---

<div class="post-metadata">

**Author:** ![touchaponk](https://avatars.discourse-cdn.com/v4/letter/t/ec9cab/32.png) [@touchaponk](https://forum.social.plus/u/touchaponk)\
**Post date:** [January 5, 2022, 2:16pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/10 "2022-01-05T14:16:08Z")

</div>

Hi @rdmitrij - sorry for the delayed response, I can confirm that this is currently a limitation of the system due to internal reactivity state. For now you will need to use `setTimeout` to help ‘tick’ the system

---

<div class="post-metadata">

**Author:** ![ncc](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@ncc](https://forum.social.plus/u/ncc)\
**Post date:** [May 2, 2023, 3:38pm UTC](https://forum.social.plus/t/hasmore-stale-after-dataupdated-event/268/11 "2023-05-02T15:38:37Z")

</div>

Hi @SocialPlus_Support , I’m still facing the same issue – my first call to `queryAllPosts` returns 20 objects and a `hasMore` of false, even though there are more posts in the database. Is there a workaround to get an accurate value of `hasMore`?
