Skip to content

multi: show upgrade banner if newer version is available on GitHub #3286

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ukane-philemon
Copy link
Contributor

@ukane-philemon ukane-philemon commented May 22, 2025

https://github.com/user-attachments/assets/7a077e62-6a2b-4744-99d2-d3e9beb6532a

https://github.com/user-attachments/assets/ecdaa6fc-99e0-436f-91ad-a11756af3eb7

The banner stays until the user upgrades.

PS: The wording was changed to direct users to the bison wallet; this is just a visual representation of the banner.

Closes #3191

continue
}

w.latestVersion = strings.Trim(response.TagName, "v")
Copy link
Member

Choose a reason for hiding this comment

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

It's possible this isnt just v1.x.x https://api.github.com/repos/decred/dcrd/releases/latest

Copy link
Contributor Author

@ukane-philemon ukane-philemon May 23, 2025

Choose a reason for hiding this comment

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

Possible yes but we’ll have to work with how dcrdex name releases, not sure why that should change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Errm, prior to v0.6.x it was name differently "DCRDEX v0.x.x" but going forward I think we should stick to one way of doing things, using the vx.x.x as tag name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

568af47 introduced gt check that should resolve your concerns @JoeGruffins.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should proly use a regex here to future-proof this.

Review comment: #3286 (comment)

Signed-off-by: Philemon Ukane <[email protected]>
@exitus1
Copy link

exitus1 commented May 23, 2025

Great feature, though wouldn't it make more sense to direct people to the website?

@dev-warrior777
Copy link
Contributor

Great feature, though wouldn't it make more sense to direct people to the website?

It would if the website and github were tightly in sync. Often there is a lag in updating the website.

@exitus1
Copy link

exitus1 commented May 23, 2025

Great feature, though wouldn't it make more sense to direct people to the website?

It would if the website and github were tightly in sync. Often there is a lag in updating the website.

This is true...but I'm just sayin' the /average user/ isn't exactly used to downloading things from Github where you have 16 different files to select from. Is updating the website when there is a new release a difficult task?

@ukane-philemon
Copy link
Contributor Author

ukane-philemon commented May 23, 2025

Great feature, though wouldn't it make more sense to direct people to the website?

It would if the website and github were tightly in sync. Often there is a lag in updating the website.

This is true...but I'm just sayin' the /average user/ isn't exactly used to downloading things from Github where you have 16 different files to select from. Is updating the website when there is a new release a difficult task?

I thought about all of the above, and now that it's also mentioned..I'll just redirect them to the website.

Is updating the website when there is a new release a difficult task

I suppose there should be a release checklist, right? @buck54321

@buck54321
Copy link
Member

The banner is too aggro. Just use a notification.

@ukane-philemon
Copy link
Contributor Author

ukane-philemon commented May 24, 2025

IMO an upgrade is a highly recommended action that is not part of the actual function of the app...it could easily be ignored if sent via notes.

@ukane-philemon ukane-philemon changed the title multi: show upgrade banner if newer version is available on GitHub multi: notify user if newer version is available on GitHub May 24, 2025
// GitHub API for the latest release. If a new release is found, it notifies the
// user with a TopicNewReleaseAvailable note.
func (c *Core) checkForNewRelease(ctx context.Context) {
ticker := time.NewTicker(3 * time.Minute)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I didn't notice there were two for loops selecting of a case. One minute or so is fine here I guess. Would be good to try once without waiting as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we try once, and it always fails, the user may theoretically never get the note, (i.e if they never run the app for 24hrs)

Comment on lines 11193 to 11194
currentVersion := strings.Split(c.cfg.Version, "-")[0]
if latestVersion > currentVersion && !strings.Contains(latestVersion, currentVersion) {
Copy link
Member

Choose a reason for hiding this comment

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

latestVersion > currentVersion isn't good for string comparison. consider that "v1.0.2" > "1.0.3" will return true. I assume there's a way to do better by splitting on decimals https://stackoverflow.com/questions/8955657/regex-pattern-to-extract-version-number-from-string

Copy link
Member

Choose a reason for hiding this comment

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

I think tests are passing because of the !strings.Contains part

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, use this

func ParseSemVer(s string) (major, minor, patch uint32, preRel, build string, err error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, use this

func ParseSemVer(s string) (major, minor, patch uint32, preRel, build string, err error) {

This would work for c.cfg.Version, but we'd proly need the regex suggestion for latestVersion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could reuse the userAppVersion function in #3289, might move the helper function to dex/version.

Copy link
Member

@JoeGruffins JoeGruffins left a comment

Choose a reason for hiding this comment

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

I'm not seeing the notification in the ui for some reason. I see it in logs though.

@ukane-philemon
Copy link
Contributor Author

I'm not seeing the notification in the ui for some reason. I see it in logs though.

Check the Recent Activity in the Notification dropdown, poke level is < success level so it won't show up in the Notification section.

Copy link
Collaborator

@martonp martonp left a comment

Choose a reason for hiding this comment

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

The github check looks good. I think for the UI, instead of having it in the notifications, there should be a bar on the top of the screen just sitting there all the time telling the user to update to a new version.

@ukane-philemon
Copy link
Contributor Author

The github check looks good. I think for the UI, instead of having it in the notifications, there should be a bar on the top of the screen just sitting there all the time telling the user to update to a new version.

That was my first iteration but @buck54321 suggested we prefer notes.

See: #3286 (comment)

@buck54321
Copy link
Member

You guys win. Do the banner. Sorry for the back and forth.

@ukane-philemon ukane-philemon changed the title multi: notify user if newer version is available on GitHub multi: show upgrade banner if newer version is available on GitHub May 29, 2025
@martonp
Copy link
Collaborator

martonp commented May 29, 2025

That was my first iteration but @buck54321 suggested we prefer notes.

Lol I missed that completely.

@@ -12,6 +12,15 @@
<link href="/css/style.css?v={{commitHash}}" rel="stylesheet">
</head>
<body class="dark{{if .UseDEXBranding}} dex-branding{{end}}">
{{if and (ne .Version .LatestVersion) .LatestVersion}}
Copy link
Member

Choose a reason for hiding this comment

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

What exactly is this comparison. Sorry.

if and is used for two comparisons, then those are, .Version != .LatestVersion and .LatestVersion existing at all?

I still think you should parse the version and probably do this somewhere else. It should compare the versions properly. Will this make our testing builds always hit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes to your first question.

Nope, doesn’t make testing builds always hit…but we can take this check away from the html template and use a single bool variable.


for {
select {
case <-ticker.C:
Copy link
Member

Choose a reason for hiding this comment

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

I may still be missing something, but this could fire once without waiting, as soon as the app is started, then go into the loop if that fails.

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

Successfully merging this pull request may close these issues.

ui: notify users when a new version is available
6 participants