Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
fix: only cache latest version for 5 minutes (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz authored Jun 22, 2024
1 parent fc046eb commit 1c759ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ type githubRelease struct {
}

var latestRelease = ""
var lastVersionCheck = time.Time{}

func GetLatestReleaseTag() string {
if latestRelease != "" {
if latestRelease != "" && time.Since(lastVersionCheck) < 5*time.Minute {
return latestRelease
}
url := "https://api.github.com/repos/getAlby/nostr-wallet-connect-next/releases"
Expand Down Expand Up @@ -75,5 +76,7 @@ func GetLatestReleaseTag() string {
"current": Tag,
}).Info("Found latest github release")

lastVersionCheck = time.Now()

return latestRelease
}

0 comments on commit 1c759ad

Please sign in to comment.