Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reaction Toggle not updating cache for publications #964

Open
1 of 2 tasks
dave4506 opened this issue Aug 20, 2024 · 3 comments
Open
1 of 2 tasks

Reaction Toggle not updating cache for publications #964

dave4506 opened this issue Aug 20, 2024 · 3 comments

Comments

@dave4506
Copy link

Describe the bug
Adding a reaction to a post NOT created by the signed-in user does not update the local apollo cache state, BUT updating a publication created by the signed-in user does result in a cache update.

To Reproduce
Provide with as much details as possible the call, the hook, the interaction with the Lens SDK that has been problematic for you. Links to public GH repos or working examples are really appreciated.

  • add a reaction to user created post
  • see that the cache is properly updated
  • add a reaction to another user's post
  • see that the cache is not updated

Feels like #854 has very similar issues to me.

Expected behaviuor
A clear and concise description of what you expected to happen.
State should update for all publications

If using the React bindings, what is the essence of your React app?

  • React Web App
  • React Native

Version of the packages you are using

"@lens-protocol/client": "^2.3.1",
    "@lens-protocol/metadata": "^1.2.0",
    "@lens-protocol/react-web": "^2.3.1",
    "@lens-protocol/wagmi": "^4.1.4",

Additional context
Add any other context about the problem here.

@dave4506
Copy link
Author

I have managed to hone in on the issue; the updateFragment function utilized by the PublicationCacheManager returns null on non "user connected" posts.

Curiously, from looking into the apollo cache, I was able to focus in on the specific condition that allows for updateFragment to work:

If in ROOT_QUERY, there is a request for profile, it seems to work as intended, if there is no query there; the local cache will not work.

@dave4506
Copy link
Author

Found the issue, for posterity sake and for feedback to core team.

The issue relates to statsFor for profiles.

In lensConfig, I DO NOT have any statsFor configured. But when I was querying for these publications, I did it with the following:

 const res = usePublications({
    where: {
      publicationTypes: [PublicationType.Post],
      metadata: {
        publishedOn: [LENS_APP_ID],
        tags: {
          all: [postTags!.txn, postTags!.chain],
        },
      },
    },

Because of publishedOn, profiles return stats just for LENS_APP_ID, there is no stats for the case of [] (i.e all apps)

This becomes an issue because when the PublicationCacheManager attempts to find the cache result, it passes variables from the global config, which was set to [] for me. This meant that profiles queried by usePublications could not be "found" because they are missing stats for the [] condition.

I have temp fixed this by simply dropping publishedOn. But to me, this is a bug to fix.

@cesarenaldi
Copy link
Member

Hey @dave4506 thank you for the detailed explanation and the temp workaround.

Your feedback is very welcome, indeed this (the interoperability of some nested field arguments) is an area we are looking at as part of the coming iteration of the Lens API. This specifically might just be simplified altogether removing the need for a lens config property and making the publishedOn enough for all use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants