cli: Make UI struct singleton

This commit is contained in:
John Brooks 2016-10-22 17:50:21 -07:00
parent d37d40def4
commit a22de02531
3 changed files with 7 additions and 7 deletions

View File

@ -35,11 +35,10 @@ func main() {
client := &Client{
Backend: rpc.NewRicochetCoreClient(conn),
}
ui := &UI{
Ui = UI{
Input: input,
Client: client,
}
client.Ui = ui
fmt.Print("Connecting to backend...\n")
@ -49,9 +48,9 @@ func main() {
os.Exit(1)
}
client.Block()
ui.PrintStatus()
Ui.PrintStatus()
client.Unblock()
}()
ui.CommandLoop()
Ui.CommandLoop()
}

View File

@ -9,7 +9,6 @@ import (
type Client struct {
Backend ricochet.RicochetCoreClient
Ui *UI
ServerStatus ricochet.ServerStatusReply
Identity ricochet.Identity
@ -227,8 +226,8 @@ func (c *Client) onContactEvent(event *ricochet.ContactEvent) {
contact, _ := c.Contacts.Deleted(data)
if c.Ui.CurrentContact == contact {
c.Ui.SetCurrentContact(nil)
if Ui.CurrentContact == contact {
Ui.SetCurrentContact(nil)
}
default:

View File

@ -10,6 +10,8 @@ import (
"strings"
)
var Ui UI
type UI struct {
Input *readline.Instance
Client *Client