Skip to content

Commit

Permalink
Display registration status
Browse files Browse the repository at this point in the history
  • Loading branch information
song50119 committed Sep 24, 2021
1 parent 90a8435 commit ce4b0dc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
12 changes: 12 additions & 0 deletions ui/page/dexclient/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dexclient
import (
"fmt"

"decred.org/dcrdex/client/core"
"decred.org/dcrdex/dex/msgjson"
)

Expand Down Expand Up @@ -54,6 +55,17 @@ func (pg *Page) readNotifications() {
select {
case n := <-ch:
fmt.Println("Recv notification", n)
fmt.Println("<INFO>", n.ID())
fmt.Println("<INFO>", n.Severity())
fmt.Println("<INFO>", n.Type())
fmt.Println("<INFO>", n.DBNote())
fmt.Println("<INFO>", n.String())
fmt.Println("<INFO>", n.Subject())

if n.Type() == core.NoteTypeFeePayment {
pg.RefreshWindow()
}
pg.refreshUser()
case <-pg.ctx.Done():
return
}
Expand Down
4 changes: 2 additions & 2 deletions ui/page/dexclient/login_modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const dexLoginModalID = "dex_login_modal"
type loginModal struct {
*load.Load
modal *decredmaterial.Modal
loggedIn func()
loggedIn func([]byte)

submit decredmaterial.Button
appPassword decredmaterial.Editor
Expand Down Expand Up @@ -63,7 +63,7 @@ func (md *loginModal) Handle() {
return
}

md.loggedIn()
md.loggedIn([]byte(md.appPassword.Editor.Text()))
md.Dismiss()
}
}
Expand Down
22 changes: 19 additions & 3 deletions ui/page/dexclient/markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dexclient

import (
"context"
"fmt"

"decred.org/dcrdex/client/core"
"gioui.org/layout"
Expand All @@ -20,6 +21,8 @@ type (
)

const MarketPageID = "Markets"

// const testDexHost = "dex-test.ssgen.io:7232"
const testDexHost = "127.0.0.1:7232"

type selectedMaket struct {
Expand Down Expand Up @@ -87,16 +90,24 @@ func (pg *Page) Layout(gtx C) D {
dims := components.UniformPadding(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
dex := pg.user.Exchanges[pg.selectedMaket.host]
if dex == nil || !dex.Connected {
return D{}
}
regConfirms, confsrequired := dex.RegConfirms, dex.ConfsRequired
if regConfirms == nil {
return D{}
}
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return pg.Theme.Label(values.TextSize14, "Waiting for confirmations...").Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
t := "In order to trade at 127.0.0.1:7232, the registration fee payment needs 4 confirmations."
t := fmt.Sprintf("In order to trade at %s, the registration fee payment needs %d confirmations.", pg.selectedMaket.host, confsrequired)
return pg.Theme.Label(values.TextSize14, t).Layout(gtx)
}),
layout.Rigid(func(gtx C) D {
t := "1/4"
t := fmt.Sprintf("%d/%d", *regConfirms, confsrequired)
return pg.Theme.Label(values.TextSize14, t).Layout(gtx)
}),
)
Expand Down Expand Up @@ -177,9 +188,14 @@ func (pg *Page) handleModals() {

if !pg.DL.IsLoggedIn && u.Initialized {
md := newloginModal(pg.Load)
md.loggedIn = func() {
md.loggedIn = func(password []byte) {
pg.refreshUser()
pg.DL.IsLoggedIn = true
if u.Assets[dexc.DefaultAssetID] != nil &&
u.Assets[dexc.DefaultAssetID].Wallet != nil &&
u.Assets[dexc.DefaultAssetID].Wallet.Open {
pg.connectDex(pg.selectedMaket.host, password)
}
}
md.Show()
return
Expand Down

0 comments on commit ce4b0dc

Please sign in to comment.