Merge branch 'alpha-updates' of cwtch.im/ui into master
This commit is contained in:
commit
44067b20a0
|
@ -1,37 +0,0 @@
|
||||||
package characters
|
|
||||||
|
|
||||||
import (
|
|
||||||
"cwtch.im/cwtch/model"
|
|
||||||
"cwtch.im/ui/go/gobjects"
|
|
||||||
"cwtch.im/ui/go/the"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CwtchListener(callback func(message *gobjects.Message), groupID string, channel chan model.Message) {
|
|
||||||
for {
|
|
||||||
m := <-channel
|
|
||||||
|
|
||||||
name := m.PeerID
|
|
||||||
if name == the.Peer.GetProfile().Onion {
|
|
||||||
name = "me"
|
|
||||||
} else {
|
|
||||||
contact := the.Peer.GetContact(m.PeerID)
|
|
||||||
if contact != nil {
|
|
||||||
name, _ = contact.GetAttribute("name")
|
|
||||||
} else {
|
|
||||||
name = m.PeerID[:16] + "..."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(&gobjects.Message{
|
|
||||||
groupID,
|
|
||||||
m.PeerID,
|
|
||||||
name,
|
|
||||||
m.Message,
|
|
||||||
"",
|
|
||||||
m.PeerID == the.Peer.GetProfile().Onion,
|
|
||||||
"0",
|
|
||||||
m.Timestamp,
|
|
||||||
false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,11 +11,12 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IncomingListener(callback func(*gobjects.Message)) {
|
func IncomingListener(callback func(*gobjects.Message), groupErrorCallback func(string,string)) {
|
||||||
q := event.NewEventQueue(1000)
|
q := event.NewEventQueue(1000)
|
||||||
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel)
|
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel)
|
||||||
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
|
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
|
||||||
the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel)
|
the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel)
|
||||||
|
the.CwtchApp.EventBus().Subscribe(event.SendMessageToGroupError, q.EventChannel)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
e := q.Next()
|
e := q.Next()
|
||||||
|
@ -52,6 +53,8 @@ func IncomingListener(callback func(*gobjects.Message)) {
|
||||||
})
|
})
|
||||||
case event.NewGroupInvite:
|
case event.NewGroupInvite:
|
||||||
log.Debugf("got a group invite!")
|
log.Debugf("got a group invite!")
|
||||||
|
case event.SendMessageToGroupError:
|
||||||
|
groupErrorCallback(e.Data[event.Signature], e.Data[event.Error])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,6 +34,7 @@ type GrandCentralDispatcher struct {
|
||||||
_ func() `signal:"ResetMessagePane"`
|
_ func() `signal:"ResetMessagePane"`
|
||||||
_ func(mID string) `signal:"Acknowledged"`
|
_ func(mID string) `signal:"Acknowledged"`
|
||||||
_ func(title string) `signal:"SetToolbarTitle"`
|
_ func(title string) `signal:"SetToolbarTitle"`
|
||||||
|
_ func(signature string, err string) `signal:"GroupSendError"`
|
||||||
|
|
||||||
// profile-area stuff
|
// profile-area stuff
|
||||||
_ func(name, onion, image string) `signal:"UpdateMyProfile"`
|
_ func(name, onion, image string) `signal:"UpdateMyProfile"`
|
||||||
|
|
|
@ -86,6 +86,10 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
return this.contacts[handle]
|
return this.contacts[handle]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *InterfaceState) AddGroupError(signature string, err string) {
|
||||||
|
this.parentGcd.GroupSendError(signature, err)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *InterfaceState) AddMessage(m *gobjects.Message) {
|
func (this *InterfaceState) AddMessage(m *gobjects.Message) {
|
||||||
this.GetContact(m.From)
|
this.GetContact(m.From)
|
||||||
|
|
||||||
|
|
2
main.go
2
main.go
|
@ -111,7 +111,7 @@ func main() {
|
||||||
|
|
||||||
// these are long-lived pollers/listeners for incoming messages and status changes
|
// these are long-lived pollers/listeners for incoming messages and status changes
|
||||||
loadCwtchData(gcd, acn)
|
loadCwtchData(gcd, acn)
|
||||||
go characters.IncomingListener(gcd.UIState.AddMessage)
|
go characters.IncomingListener(gcd.UIState.AddMessage, gcd.UIState.AddGroupError)
|
||||||
go characters.PostmanPat(gcd.OutgoingMessages)
|
go characters.PostmanPat(gcd.OutgoingMessages)
|
||||||
go characters.TorStatusPoller(gcd.TorStatus, acn)
|
go characters.TorStatusPoller(gcd.TorStatus, acn)
|
||||||
go characters.PresencePoller(gcd.UIState.GetContact, gcd.UIState.AddContact, gcd.UIState.UpdateContact)
|
go characters.PresencePoller(gcd.UIState.GetContact, gcd.UIState.AddContact, gcd.UIState.UpdateContact)
|
||||||
|
|
|
@ -23,6 +23,7 @@ RowLayout {
|
||||||
property alias timestamp: ts.text
|
property alias timestamp: ts.text
|
||||||
property alias image: imgProfile.source
|
property alias image: imgProfile.source
|
||||||
property alias status: imgProfile.status
|
property alias status: imgProfile.status
|
||||||
|
property string error
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: gcd
|
target: gcd
|
||||||
|
@ -33,6 +34,12 @@ RowLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onGroupSendError: function(mid, error) {
|
||||||
|
if (mid == messageID) {
|
||||||
|
root.error = error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -130,10 +137,17 @@ RowLayout {
|
||||||
Image { // ACKNOWLEDGEMENT ICON
|
Image { // ACKNOWLEDGEMENT ICON
|
||||||
id: ack
|
id: ack
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
source: root.ackd ? "qrc:/qml/images/fontawesome/regular/check-circle.svg" : "qrc:/qml/images/fontawesome/regular/hourglass.svg"
|
source: root.error != "" ? "qrc:/qml/images/fontawesome/regular/window-close.svg" : (root.ackd ? "qrc:/qml/images/fontawesome/regular/check-circle.svg" : "qrc:/qml/images/fontawesome/regular/hourglass.svg")
|
||||||
height: 10
|
height: 10
|
||||||
sourceSize.height: 10
|
sourceSize.height: 10
|
||||||
visible: fromMe
|
visible: fromMe
|
||||||
|
ToolTip.visible: ma.containsMouse
|
||||||
|
ToolTip.text: root.error != "" ? qsTr("Could not send this message: ") + qsTr(root.error) : (root.ackd ? qsTr("Acknowledged") : qsTr("Pending"))
|
||||||
|
MouseArea {
|
||||||
|
id: ma
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue