GithubHelp home page GithubHelp logo

In version 1.01 of the "@lens-protocol/react" package, when using the "useExplorePublications" hook with "sortCriteria: PublicationSortCriteria.Latest", there is an issue where the next page cannot be successfully requested. about lens-sdk HOT 13 CLOSED

lens-protocol avatar lens-protocol commented on July 24, 2024
In version 1.01 of the "@lens-protocol/react" package, when using the "useExplorePublications" hook with "sortCriteria: PublicationSortCriteria.Latest", there is an issue where the next page cannot be successfully requested.

from lens-sdk.

Comments (13)

cesarenaldi avatar cesarenaldi commented on July 24, 2024 2

@jingledongding an update on this. I managed to reproduce a pagination issue on a different query. Not sure if this is related but seems to manifest itself in a very similar way to your issue. I'll keep you in the loop when we know more from the Lens API team.

from lens-sdk.

krzysu avatar krzysu commented on July 24, 2024 2

I think this issue is related to #382 and there is a fix in v.1.1.1 that was released today, @jingledongding could you try if the v1.1.1 works for you?

npm install @lens-protocol/[email protected]

from lens-sdk.

cesarenaldi avatar cesarenaldi commented on July 24, 2024 1

Hi @jingledongding , thank you for reporting this.

We recently promoted 1.1.0 to stable.. can you please try to upgrade and see if the problem persist?

From your description I am inclined to think of an API issue, but I wasn't able to reproduce anything from my testing.

In 1.1.0 we also introduced a prev callback which helps with retrieving newer results. Wondering if this could be of any help for your usage.

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

When I switch the sortCriteria filter to PublicationSortCriteria.TopCollected, everything works fine.

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

Thank you for your assistance. I will try it out soon.

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

@cesarenaldi Hi,I have upgraded to version 1.1.0 and conducted a series of tests. It seems that the issue lies with the data returned on the first request, as it appears to be unexpected and prevents me from obtaining the next page of data. When I skip the hasMore check and directly make the next request, I am able to retrieve the data. However, this also prevents me from merging it with the cache. Additionally, if I make another next page request, it resets back to the initial pointer.

code:
const { data: publications, loading, hasMore, next, } = useExplorePublications({ limit: 20, sortCriteria: PublicationSortCriteria.Latest, publicationTypes: [PublicationTypes.Post], })
first query:
{ "operationName": "ExplorePublications", "variables": { "limit": 10, "publicationTypes": [ "POST" ], "sortCriteria": "LATEST", "observerId": null, "sources": [], } "query":{...}, }
response data:
{ "data": { "result":{ "item":[...], "pageInfo": { "__typename": "PaginatedResultInfo", "prev": "{\"timestamp\":1,\"offset\":0}", "next": "{\"timestamp\":1,\"offset\":10}", "totalCount": null }, "__typename": "ExplorePublicationResult", } } }

The following is an example of data that allows for a successful request for the next page.
code:
const { data: latestCreateds, hasMore: latestHasMore, next: latestNext, } = useExploreProfiles({ sortCriteria: ProfileSortCriteria.LatestCreated, limit: 20, observerId: activeProfile?.id, })
query:
{ "operationName": "ExploreProfiles", "variables": { "limit": 20, "observerId": null, "sortCriteria": "LATEST_CREATED", "sources": [] }, "query":{...}, }
response data:
{ "data": { "result":{ "item":[...], "pageInfo": { "__typename": "PaginatedResultInfo", "prev": "{\"offset\":0}", "next": "{\"offset\":20}", "totalCount": 117761 }, "__typename": "ExploreProfileResult" } } }

I'm not familiar with the repository and don't know what's happening internally. Can you help me take a look, please?

from lens-sdk.

cesarenaldi avatar cesarenaldi commented on July 24, 2024

Thank you @jingledongding for these details. We'll investigate further.

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

Thank you for your kind words. Keep up the great work!

from lens-sdk.

cesarenaldi avatar cesarenaldi commented on July 24, 2024

@cesarenaldi Hi,I have upgraded to version 1.1.0 and conducted a series of tests. It seems that the issue lies with the data returned on the first request, as it appears to be unexpected and prevents me from obtaining the next page of data. When I skip the hasMore check and directly make the next request, I am able to retrieve the data. However, this also prevents me from merging it with the cache. Additionally, if I make another next page request, it resets back to the initial pointer.

code: const { data: publications, loading, hasMore, next, } = useExplorePublications({ limit: 20, sortCriteria: PublicationSortCriteria.Latest, publicationTypes: [PublicationTypes.Post], }) first query: { "operationName": "ExplorePublications", "variables": { "limit": 10, "publicationTypes": [ "POST" ], "sortCriteria": "LATEST", "observerId": null, "sources": [], } "query":{...}, } response data: { "data": { "result":{ "item":[...], "pageInfo": { "__typename": "PaginatedResultInfo", "prev": "{\"timestamp\":1,\"offset\":0}", "next": "{\"timestamp\":1,\"offset\":10}", "totalCount": null }, "__typename": "ExplorePublicationResult", } } }

The following is an example of data that allows for a successful request for the next page. code: const { data: latestCreateds, hasMore: latestHasMore, next: latestNext, } = useExploreProfiles({ sortCriteria: ProfileSortCriteria.LatestCreated, limit: 20, observerId: activeProfile?.id, }) query: { "operationName": "ExploreProfiles", "variables": { "limit": 20, "observerId": null, "sortCriteria": "LATEST_CREATED", "sources": [] }, "query":{...}, } response data: { "data": { "result":{ "item":[...], "pageInfo": { "__typename": "PaginatedResultInfo", "prev": "{\"offset\":0}", "next": "{\"offset\":20}", "totalCount": 117761 }, "__typename": "ExploreProfileResult" } } }

I'm not familiar with the repository and don't know what's happening internally. Can you help me take a look, please?

@jingledongding I was looking at your examples again and there's 2 question I have.

The first one is:

are you sure the query for the first call belongs to the use of useExploreProfiles few lines above? I see the limit in the useExploreProfiles call is set to 20 but the query has 10.

Also is it possible in your tests you are calling next "too early", before the initial request loading transitioned from true to false?

from lens-sdk.

melissafzhang avatar melissafzhang commented on July 24, 2024

Potentially related but we're also experiencing issues with usePublications hook where hasMore is always false even though the first query has pageInfo.next defined.

const LensFeed = ({ profileId }: { profileId: ProfileId }) => {
  const {
    data: publications,
    hasMore,
    next,
    loading,
  } = usePublications({
    profileId,
    limit: 10,
  });

  return (
    <div className={styles.feed}>
      {publications?.map((post) => (
        <LensPost publicationID={post.id} key={post.id} />
      ))}
      {hasMore && (
        <Button onClick={next} buttonType="modeOnBackground" loading={loading}>
          See More
        </Button>
      )}
    </div>
  );
};

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

I apologize for the mistake in the example code. To clarify, the correct value for "limit" should be 10

from lens-sdk.

jingledongding avatar jingledongding commented on July 24, 2024

awesome, it is very useful for me

from lens-sdk.

krzysu avatar krzysu commented on July 24, 2024

then I'm closing this issue, thanks all for your participation!

from lens-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.