Merge branch 'addContact' of dan/ui into master
the build was successful
Details
the build was successful
Details
This commit is contained in:
commit
628e414376
|
@ -22,6 +22,7 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
|
||||||
the.EventBus.Subscribe(event.SendMessageToPeerError, q)
|
the.EventBus.Subscribe(event.SendMessageToPeerError, q)
|
||||||
the.EventBus.Subscribe(event.ServerStateChange, q)
|
the.EventBus.Subscribe(event.ServerStateChange, q)
|
||||||
the.EventBus.Subscribe(event.PeerStateChange, q)
|
the.EventBus.Subscribe(event.PeerStateChange, q)
|
||||||
|
the.EventBus.Subscribe(event.PeerCreated, q)
|
||||||
subscribed <- true
|
subscribed <- true
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
@ -75,6 +76,9 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
|
||||||
if err == nil && group != nil {
|
if err == nil && group != nil {
|
||||||
uiState.AddContact(gid)
|
uiState.AddContact(gid)
|
||||||
}
|
}
|
||||||
|
case event.PeerCreated:
|
||||||
|
onion := e.Data[event.RemotePeer]
|
||||||
|
uiState.AddContact(onion)
|
||||||
case event.SendMessageToGroupError:
|
case event.SendMessageToGroupError:
|
||||||
uiState.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error])
|
uiState.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error])
|
||||||
case event.SendMessageToPeerError:
|
case event.SendMessageToPeerError:
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package gobjects
|
|
||||||
|
|
||||||
// a Letter is a very simple message object passed to us from the UI
|
|
||||||
type Letter struct {
|
|
||||||
To, Message string
|
|
||||||
MID string
|
|
||||||
}
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
type GrandCentralDispatcher struct {
|
type GrandCentralDispatcher struct {
|
||||||
core.QObject
|
core.QObject
|
||||||
|
|
||||||
OutgoingMessages chan gobjects.Letter
|
|
||||||
UIState InterfaceState
|
UIState InterfaceState
|
||||||
QMLEngine *qml.QQmlApplicationEngine
|
QMLEngine *qml.QQmlApplicationEngine
|
||||||
Translator *core.QTranslator
|
Translator *core.QTranslator
|
||||||
|
@ -66,6 +65,7 @@ type GrandCentralDispatcher struct {
|
||||||
_ func(onion string) `signal:"loadMessagesPane,auto"`
|
_ func(onion string) `signal:"loadMessagesPane,auto"`
|
||||||
_ func(signal string) `signal:"broadcast,auto"` // convenience relay signal
|
_ func(signal string) `signal:"broadcast,auto"` // convenience relay signal
|
||||||
_ func(str string) `signal:"importString,auto"`
|
_ func(str string) `signal:"importString,auto"`
|
||||||
|
_ func(str string) `signal:"createContact,auto"`
|
||||||
_ func(str string) `signal:"popup,auto"`
|
_ func(str string) `signal:"popup,auto"`
|
||||||
_ func(nick string) `signal:"updateNick,auto"`
|
_ func(nick string) `signal:"updateNick,auto"`
|
||||||
_ func(server, groupName string) `signal:"createGroup,auto"`
|
_ func(server, groupName string) `signal:"createGroup,auto"`
|
||||||
|
@ -339,6 +339,14 @@ func (this *GrandCentralDispatcher) broadcast(signal string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *GrandCentralDispatcher) createContact(onion string) {
|
||||||
|
if contact := the.Peer.GetContact(onion); contact != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
the.Peer.AddContact(onion, onion, false)
|
||||||
|
the.Peer.PeerWithOnion(onion)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) importString(str string) {
|
func (this *GrandCentralDispatcher) importString(str string) {
|
||||||
if len(str) < 5 {
|
if len(str) < 5 {
|
||||||
log.Debugf("ignoring short string")
|
log.Debugf("ignoring short string")
|
||||||
|
@ -397,6 +405,9 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
||||||
if checkc != nil {
|
if checkc != nil {
|
||||||
this.InvokePopup("already have this contact")
|
this.InvokePopup("already have this contact")
|
||||||
return //TODO: bring them to the duplicate
|
return //TODO: bring them to the duplicate
|
||||||
|
} else {
|
||||||
|
the.Peer.AddContact(name, onion, false)
|
||||||
|
the.Peer.PeerWithOnion(onion)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.UIState.AddContact(onion)
|
this.UIState.AddContact(onion)
|
||||||
|
|
2
main.go
2
main.go
|
@ -4,7 +4,6 @@ import (
|
||||||
libapp "cwtch.im/cwtch/app"
|
libapp "cwtch.im/cwtch/app"
|
||||||
"cwtch.im/cwtch/event/bridge"
|
"cwtch.im/cwtch/event/bridge"
|
||||||
"cwtch.im/ui/go/characters"
|
"cwtch.im/ui/go/characters"
|
||||||
"cwtch.im/ui/go/gobjects"
|
|
||||||
"cwtch.im/ui/go/gothings"
|
"cwtch.im/ui/go/gothings"
|
||||||
"cwtch.im/ui/go/gothings/android"
|
"cwtch.im/ui/go/gothings/android"
|
||||||
"cwtch.im/ui/go/the"
|
"cwtch.im/ui/go/the"
|
||||||
|
@ -139,7 +138,6 @@ func mainUi(flagLocal bool, flagClientUI bool) {
|
||||||
gcd.SetBuildDate("now")
|
gcd.SetBuildDate("now")
|
||||||
}
|
}
|
||||||
gcd.UIState = gothings.NewUIState(gcd)
|
gcd.UIState = gothings.NewUIState(gcd)
|
||||||
gcd.OutgoingMessages = make(chan gobjects.Letter, 1000)
|
|
||||||
|
|
||||||
//TODO: put theme stuff somewhere better
|
//TODO: put theme stuff somewhere better
|
||||||
gcd.SetThemeScale(1.0)
|
gcd.SetThemeScale(1.0)
|
||||||
|
|
|
@ -48,6 +48,12 @@ ColumnLayout {
|
||||||
target: gcd
|
target: gcd
|
||||||
|
|
||||||
onAddContact: function(handle, displayName, image, server, badge, status, blocked, loading) {
|
onAddContact: function(handle, displayName, image, server, badge, status, blocked, loading) {
|
||||||
|
for (var i = 0; i < contactsModel.count; i++) {
|
||||||
|
if (contactsModel.get(i)["_handle"] == handle) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contactsModel.append({
|
contactsModel.append({
|
||||||
"_handle": handle,
|
"_handle": handle,
|
||||||
"_displayName": displayName + (blocked ? " (blocked)" : "" ),
|
"_displayName": displayName + (blocked ? " (blocked)" : "" ),
|
||||||
|
|
|
@ -62,6 +62,7 @@ Item {
|
||||||
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
gcd.createContact(from)
|
||||||
gcd.broadcast("ResetMessagePane")
|
gcd.broadcast("ResetMessagePane")
|
||||||
theStack.pane = theStack.messagePane
|
theStack.pane = theStack.messagePane
|
||||||
gcd.loadMessagesPane(from)
|
gcd.loadMessagesPane(from)
|
||||||
|
|
Reference in New Issue