Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Conversation

ThisIsMissEm
Copy link
Contributor

@ThisIsMissEm ThisIsMissEm commented Oct 13, 2022

Currently when using <SessionProvider> it automatically tries to load the WebID & associated Profile Documents, in most applications, this is okay, but when building a start/provisioning application, this behaviour is not desirable as the user does not yet have a WebID or Profile.

This change adds an experimental prop to <SessionProvider> that allows disabling the automatic loading of profiles. This prop is considered experimental as the API has not yet stabilised and may change in a future major version.

Usage

<SessionProvider skipLoadingProfile>
  ...
</SessionProvider>

Checklist

  • All acceptance criteria are met.
  • Relevant documentation, if any, has been written/updated.
  • The changelog has been updated, if applicable.
  • New functions/types have been exported in index.ts, if applicable.
  • New modules (i.e. new .ts files) are listed in the exports field in package.json, if applicable.
  • New modules (i.e. new .ts files) are listed in the typedocOptions.entryPoints field in tsconfig.json, if applicable.
  • Commits in this PR are minimal and have descriptive commit messages.

Comment on lines -125 to -130
sessionInfo?.webId !== undefined
? getProfileAll(sessionInfo?.webId, {
fetch: session.fetch,
})
: undefined
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the issue is that getProfileAll fails due to a network error if the WebID document isn't provisioned. If that's correct, could this be fixed by catching exceptions, and behaving as if the profile isn't available? If that was possible, it would be easier than having to manually skip this step.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now, manually skipping is the best approach, as I don't think we should be pre-fetching the profile/webid anymore, and instead provide a dedicated hook for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, due to how this code is structured, the catch at the end can catch more than what it intends to, we should probably switch this from a promise chain to async/await

@ThisIsMissEm ThisIsMissEm marked this pull request as ready for review October 14, 2022 18:00
@ThisIsMissEm ThisIsMissEm requested review from a team as code owners October 14, 2022 18:00
This is useful when using the React SDK to build a start/provisioning app, where the user will be able to login, but won't yet have a profile or WebID
@ThisIsMissEm ThisIsMissEm force-pushed the feat/allow-skipping-loading-the-profile branch from a83ea1b to 6403ce0 Compare October 19, 2022 19:52
@ThisIsMissEm ThisIsMissEm merged commit 6980adf into main Oct 19, 2022
@ThisIsMissEm ThisIsMissEm deleted the feat/allow-skipping-loading-the-profile branch October 19, 2022 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants