Skip to content

Commit

Permalink
client: Use the app build version as Version in UI in hamburger menu d…
Browse files Browse the repository at this point in the history
…ecred#2.

	- This is a rework of decred#3096 and keeps the Build ID in the
	  settings dialog.

	- Webpack Build ID for caching site/dist build will be
	  addressed in another PR if required.
  • Loading branch information
dev-warrior777 committed Jan 31, 2025
1 parent 5fe8b39 commit 19f990e
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 7 deletions.
4 changes: 3 additions & 1 deletion client/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ type Config struct {
// Web creates a configuration for the webserver. This is a Config method
// instead of a WebConfig method because Language is an app-level setting used
// by both core and rpcserver.
func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc bool) *webserver.Config {
func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc bool, appVersion string) *webserver.Config {
addr := cfg.WebAddr
host, _, err := net.SplitHostPort(addr)
if err == nil && host != "" {
Expand Down Expand Up @@ -197,6 +197,7 @@ func (cfg *Config) Web(c *core.Core, mm *mm.MarketMaker, log dex.Logger, utc boo
KeyFile: keyFile,
Language: cfg.Language,
Tor: cfg.Tor,
AppVersion: appVersion,
}
}

Expand Down Expand Up @@ -349,6 +350,7 @@ func ResolveConfig(appData string, cfg *Config) error {
if cfg.MMConfig.EventLogDBPath == "" {
cfg.MMConfig.EventLogDBPath = defaultMMEventLogDBPath
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion client/cmd/bisonw-desktop/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func mainCore() error {
}()
}

webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc))
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc, app.Version))
if err != nil {
return fmt.Errorf("failed creating web server: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion client/cmd/bisonw/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func runCore(cfg *app.Config) error {
}

if !cfg.NoWeb {
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc))
webSrv, err := webserver.New(cfg.Web(clientCore, marketMaker, logMaker.Logger("WEB"), utc, app.Version))
if err != nil {
return fmt.Errorf("failed creating web server: %w", err)
}
Expand Down
4 changes: 4 additions & 0 deletions client/webserver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type CommonArguments struct {
UserInfo *userInfo
Title string
UseDEXBranding bool
Version string
}

// Create the CommonArguments for the request.
Expand All @@ -66,6 +67,7 @@ func (s *WebServer) commonArgs(r *http.Request, title string) *CommonArguments {
UserInfo: extractUserInfo(r),
Title: title,
UseDEXBranding: s.useDEXBranding,
Version: s.appVersion,
}
}

Expand Down Expand Up @@ -292,13 +294,15 @@ func (s *WebServer) handleSettings(w http.ResponseWriter, r *http.Request) {
FiatCurrency string
Exchanges map[string]*core.Exchange
IsInitialized bool
AppVersion string
}{
CommonArguments: *common,
KnownExchanges: s.knownUnregisteredExchanges(xcs),
FiatCurrency: core.DefaultFiatCurrency,
FiatRateSources: s.core.FiatRateSources(),
Exchanges: xcs,
IsInitialized: s.core.IsInitialized(),
AppVersion: s.appVersion,
}
s.sendTemplate(w, "settings", data)
}
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/ar.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ var Ar = map[string]*intl.Translation{
"Export Account": {T: "تصدير الحساب"},
"simultaneous_servers_msg": {T: "يدعم عميل منصة المبادلات اللامركزية لديكريد الاستخدام المتزامن لأي عدد من خوادم منصة المبادلات اللامركزية DEX."},
"Change App Password": {T: "تغيير كلمة مرور التطبيق"},
"Version": {T: "إصدار"},
"Build ID": {T: "معرف البنية"},
"Connect": {T: "اتصل"},
"Send": {T: "ارسال"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/de-de.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ var DeDE = map[string]*intl.Translation{
"browser_ntfn_blocked": {T: "Browser-Benachrichtigungen sind derzeit blockiert. Heben die Blockierung dieser Seite in Ihrem Browser auf, um Benachrichtigungen zu erhalten."},
"enable_browser_ntfn_info": {T: "Benachrichtigungen auf dem Desktop erscheinen auch dann, wenn dieses Fenster nicht aktiv ist. Dies kann nützlich sein, wenn Sie andere Anwendungen aktiviert haben, da Sie dann Benachrichtigungen über Aktivitäten auf Bison Wallet erhalten. Sie können die Arten von Benachrichtigungen, die Sie erhalten möchten, unten anpassen."},
"Save Notifications": {T: "Benachrichtigungen Speichern"},
"Version": {T: "Version"},
"Build ID": {T: "Build ID"},
"Connect": {T: "Verbinden"},
"Send": {T: "Senden"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/en-us.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ var EnUS = map[string]*intl.Translation{
"companion_app_tor_needed": {T: "Tor must be enabled for this."},
"Pair companion app": {T: "Pair companion app"},
"Download APK": {T: "Download APK"},
"Version": {T: "Version"},
"Build ID": {T: "Build ID"},
"Connect": {T: "Connect"},
"Send": {T: "Send"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/pl-pl.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var PlPL = map[string]*intl.Translation{
"Export Account": {T: "Eksportuj konto"},
"simultaneous_servers_msg": {T: "Klient Decred DEX wspiera jednoczesne korzystanie z wielu serwerów DEX."},
"Change App Password": {T: "Zmień hasło aplikacji"},
"Version": {T: "Wersja"},
"Build ID": {T: "ID builda"},
"Connect": {T: "Połącz"},
"Withdraw": {T: "Wypłać"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/pt-br.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var PtBr = map[string]*intl.Translation{
"Export Account": {T: "Exportar Conta"},
"simultaneous_servers_msg": {T: "O cliente da DEX suporta simultâneos números de servidores DEX."},
"Change App Password": {T: "Trocar Senha do aplicativo"},
"Version": {T: "Versão"},
"Build ID": {T: "ID da Build"},
"Connect": {T: "Conectar"},
"Withdraw": {T: "Retirar"},
Expand Down
1 change: 1 addition & 0 deletions client/webserver/locales/zh-cn.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ var ZhCN = map[string]*intl.Translation{
"browser_ntfn_blocked": {T: "浏览器通知目前被阻止。请在浏览器中解除对该站点的阻止,以接收通知。"},
"enable_browser_ntfn_info": {T: "即使此窗口不活跃,桌面通知仍会出现。当您打开其他应用程序时,这会很有帮助,因为您将收到 DCRDEX 事件的通知。您可以在下方自定义您希望接收的通知类型。"},
"Save Notifications": {T: "保存通知"},
"Version": {T: "版本"},
"Build ID": {T: "构建 ID"},
"Connect": {T: "连接"},
"Send": {T: "发送"},
Expand Down
8 changes: 7 additions & 1 deletion client/webserver/site/src/html/bodybuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<span class="ico-barchart fs16 me-2"></span>
[[[Market Making]]]
</a>
<a href="/settings" class="demi hoverbright plainlink d-flex align-items-center py-1">
<a href="/settings" class="demi hoverbright plainlink d-flex align-items-center py-1 authed-only">
<span class="ico-settings fs16 me-2"></span>
[[[Settings]]]
</a>
Expand All @@ -123,6 +123,12 @@
<span class="ico-profile fs16 me-2"></span>
[[[Sign Out]]]
</div>
<div class="demi d-flex align-items-center py-1" id="version">
<br>
<div class="flex-center">
[[[Version]]] {{.Version}}
</div>
</div>
</div>

</header>
Expand Down
9 changes: 6 additions & 3 deletions client/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,10 @@ type Config struct {
// should be used by default since site files from older distributions may
// be present on the disk. When NoEmbed is true, this also implies reloading
// and execution of html templates on each request.
NoEmbed bool
HttpProf bool
Tor bool
NoEmbed bool
HttpProf bool
Tor bool
AppVersion string
}

type valStamp struct {
Expand Down Expand Up @@ -277,6 +278,7 @@ type WebServer struct {
bondBuf map[uint32]valStamp

useDEXBranding bool
appVersion string
}

// New is the constructor for a new WebServer. CustomSiteDir in the Config can
Expand Down Expand Up @@ -403,6 +405,7 @@ func New(cfg *Config) (*WebServer, error) {
tor: cfg.Tor,
bondBuf: map[uint32]valStamp{},
useDEXBranding: useDEXBranding,
appVersion: cfg.AppVersion,
}
s.lang.Store(lang)

Expand Down

0 comments on commit 19f990e

Please sign in to comment.