lens-protocol/lens-sdk

@lens-protocol/react-web

wangzhiyi189 opened this issue · 4 comments

Using useSetProfileMetadata to modify the profile, the profile obtained by useSession the next day is up-to-date. Why is there such a long delay?

@wangzhiyi189 the change normally takes an handful of seconds unless there is an issue. When it happens it's often an issue with congested network.

As general guidance, if you wait for completion, by the time the result.value.waitForCompletion() returns the useSession should return updated profile.

const { execute, loading } = useSetProfileMetadata();

// ...

const update = async () => {
  const result = await execute({ metadataURI });

  // detect if an early error occurred
  if (result.isFailure()) {
    window.alert(result.error.message);
    return;
  }

  // optional: wait for the transaction to be mined and indexed
  const completion = await result.value.waitForCompletion();

  // detect if a minining/indexing error occurred
  if (completion.isFailure()) {
    window.alert(completion.error.message);
    return;
  }

  // success!
  window.alert("Profile Metadata updated!");
};

// ...

If not, it's there is an issue we would need to investigate. Can you please confirm if this is still happening or not?

@cesarenaldi I modified the data using useSetProfileMetadata. result.value.waitForCompletion() returns undefined, as does https://lens-sdk-example-web-wagmi.vercel.app/

Investigating this issue on the API side.

Just to clarify on small thing for a correct understanding, the result.value.waitForCompletion() for useSetProfileMetadata is meant to not yield a value. It's just to opt-in into waiting until completed (some apps UX might need to wait, others don't).

Still the useSession should seamlessly update with the new profile metadata as soon as completed. I see an issue on testnet in my tests. Investigating...

@wangzhiyi189 the Lens API issue that was causing this is resolved.