forked from cwtch.im/ui
Merge branch 'addContact' of dan/ui into master
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.ServerStateChange, q)
|
||||
the.EventBus.Subscribe(event.PeerStateChange, q)
|
||||
the.EventBus.Subscribe(event.PeerCreated, q)
|
||||
subscribed <- true
|
||||
|
||||
for {
|
||||
|
@ -75,6 +76,9 @@ func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) {
|
|||
if err == nil && group != nil {
|
||||
uiState.AddContact(gid)
|
||||
}
|
||||
case event.PeerCreated:
|
||||
onion := e.Data[event.RemotePeer]
|
||||
uiState.AddContact(onion)
|
||||
case event.SendMessageToGroupError:
|
||||
uiState.AddSendMessageError(e.Data[event.GroupServer], e.Data[event.Signature], e.Data[event.Error])
|
||||
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,10 +19,9 @@ import (
|
|||
type GrandCentralDispatcher struct {
|
||||
core.QObject
|
||||
|
||||
OutgoingMessages chan gobjects.Letter
|
||||
UIState InterfaceState
|
||||
QMLEngine *qml.QQmlApplicationEngine
|
||||
Translator *core.QTranslator
|
||||
UIState InterfaceState
|
||||
QMLEngine *qml.QQmlApplicationEngine
|
||||
Translator *core.QTranslator
|
||||
|
||||
_ string `property:"os"`
|
||||
_ string `property:"currentOpenConversation"`
|
||||
|
@ -66,6 +65,7 @@ type GrandCentralDispatcher struct {
|
|||
_ func(onion string) `signal:"loadMessagesPane,auto"`
|
||||
_ func(signal string) `signal:"broadcast,auto"` // convenience relay signal
|
||||
_ func(str string) `signal:"importString,auto"`
|
||||
_ func(str string) `signal:"createContact,auto"`
|
||||
_ func(str string) `signal:"popup,auto"`
|
||||
_ func(nick string) `signal:"updateNick,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) {
|
||||
if len(str) < 5 {
|
||||
log.Debugf("ignoring short string")
|
||||
|
@ -397,6 +405,9 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
|||
if checkc != nil {
|
||||
this.InvokePopup("already have this contact")
|
||||
return //TODO: bring them to the duplicate
|
||||
} else {
|
||||
the.Peer.AddContact(name, onion, false)
|
||||
the.Peer.PeerWithOnion(onion)
|
||||
}
|
||||
|
||||
this.UIState.AddContact(onion)
|
||||
|
|
2
main.go
2
main.go
|
@ -4,7 +4,6 @@ import (
|
|||
libapp "cwtch.im/cwtch/app"
|
||||
"cwtch.im/cwtch/event/bridge"
|
||||
"cwtch.im/ui/go/characters"
|
||||
"cwtch.im/ui/go/gobjects"
|
||||
"cwtch.im/ui/go/gothings"
|
||||
"cwtch.im/ui/go/gothings/android"
|
||||
"cwtch.im/ui/go/the"
|
||||
|
@ -139,7 +138,6 @@ func mainUi(flagLocal bool, flagClientUI bool) {
|
|||
gcd.SetBuildDate("now")
|
||||
}
|
||||
gcd.UIState = gothings.NewUIState(gcd)
|
||||
gcd.OutgoingMessages = make(chan gobjects.Letter, 1000)
|
||||
|
||||
//TODO: put theme stuff somewhere better
|
||||
gcd.SetThemeScale(1.0)
|
||||
|
|
|
@ -48,6 +48,12 @@ ColumnLayout {
|
|||
target: gcd
|
||||
|
||||
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({
|
||||
"_handle": handle,
|
||||
"_displayName": displayName + (blocked ? " (blocked)" : "" ),
|
||||
|
|
|
@ -62,6 +62,7 @@ Item {
|
|||
|
||||
|
||||
onClicked: {
|
||||
gcd.createContact(from)
|
||||
gcd.broadcast("ResetMessagePane")
|
||||
theStack.pane = theStack.messagePane
|
||||
gcd.loadMessagesPane(from)
|
||||
|
|
Loading…
Reference in New Issue