Update notice when new version is live #223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi!
I was looking into the option to notify users when a new version is available, and add a little bit of code to do just that. It uses the GitHub API to retrieve data about releases, and compares the
tag_name
to the version of the running instance (viaprocess.env.VERSION
).When a new version is available, a banner is displayed on top of pages when logged in. As I'm writing this I notice a Toast-component as well, but I don't know what's the right trade-off between the importance of updating, user-friendliness and visibility.
At the moment, although it's wrapped in useMemo, it will pretty much fetch the GitHub API on every render, which of course is a tad overkill. Storing the last time it checked for a new version, and the latest version at that moment in Local- or Sessionstorage to check once every session or day, would probably be a better option. I have never worked with Redux however, so I didn't implement it as of now.
Consider this PR more of a proof of concept as of now! Would love to hear some thoughts.
Edit: this uses v3 of the GitHub API, which is still REST. I assume this will be supported for some time, although they seem to be actively pushing to using the GraphQL version. GitHub states you should explicitely state the version in an Accept header, this is not implemented here, but it still works.