cli: Make UI struct singleton
This commit is contained in:
parent
d37d40def4
commit
a22de02531
|
@ -35,11 +35,10 @@ func main() {
|
||||||
client := &Client{
|
client := &Client{
|
||||||
Backend: rpc.NewRicochetCoreClient(conn),
|
Backend: rpc.NewRicochetCoreClient(conn),
|
||||||
}
|
}
|
||||||
ui := &UI{
|
Ui = UI{
|
||||||
Input: input,
|
Input: input,
|
||||||
Client: client,
|
Client: client,
|
||||||
}
|
}
|
||||||
client.Ui = ui
|
|
||||||
|
|
||||||
fmt.Print("Connecting to backend...\n")
|
fmt.Print("Connecting to backend...\n")
|
||||||
|
|
||||||
|
@ -49,9 +48,9 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
client.Block()
|
client.Block()
|
||||||
ui.PrintStatus()
|
Ui.PrintStatus()
|
||||||
client.Unblock()
|
client.Unblock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ui.CommandLoop()
|
Ui.CommandLoop()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
Backend ricochet.RicochetCoreClient
|
Backend ricochet.RicochetCoreClient
|
||||||
Ui *UI
|
|
||||||
|
|
||||||
ServerStatus ricochet.ServerStatusReply
|
ServerStatus ricochet.ServerStatusReply
|
||||||
Identity ricochet.Identity
|
Identity ricochet.Identity
|
||||||
|
@ -227,8 +226,8 @@ func (c *Client) onContactEvent(event *ricochet.ContactEvent) {
|
||||||
|
|
||||||
contact, _ := c.Contacts.Deleted(data)
|
contact, _ := c.Contacts.Deleted(data)
|
||||||
|
|
||||||
if c.Ui.CurrentContact == contact {
|
if Ui.CurrentContact == contact {
|
||||||
c.Ui.SetCurrentContact(nil)
|
Ui.SetCurrentContact(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue