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{ 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()
} }

View File

@ -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:

View File

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