Merge branch 'alpha-updates' of cwtch.im/ui into master

This commit is contained in:
erinn 2019-02-20 21:49:40 +00:00 committed by Gogs
commit 44067b20a0
6 changed files with 26 additions and 41 deletions

View File

@ -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,
})
}
}

View File

@ -11,11 +11,12 @@ import (
"time"
)
func IncomingListener(callback func(*gobjects.Message)) {
func IncomingListener(callback func(*gobjects.Message), groupErrorCallback func(string,string)) {
q := event.NewEventQueue(1000)
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromPeer, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.SendMessageToGroupError, q.EventChannel)
for {
e := q.Next()
@ -52,6 +53,8 @@ func IncomingListener(callback func(*gobjects.Message)) {
})
case event.NewGroupInvite:
log.Debugf("got a group invite!")
case event.SendMessageToGroupError:
groupErrorCallback(e.Data[event.Signature], e.Data[event.Error])
}
}
}

View File

@ -32,8 +32,9 @@ type GrandCentralDispatcher struct {
_ func(handle, from, displayName, message, image string, mID string, fromMe bool, ts string, ackd bool) `signal:"AppendMessage"`
_ func() `signal:"ClearMessages"`
_ func() `signal:"ResetMessagePane"`
_ func(mID string) `signal:"Acknowledged"`
_ func(mID string) `signal:"Acknowledged"`
_ func(title string) `signal:"SetToolbarTitle"`
_ func(signature string, err string) `signal:"GroupSendError"`
// profile-area stuff
_ func(name, onion, image string) `signal:"UpdateMyProfile"`

View File

@ -86,6 +86,10 @@ func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
return this.contacts[handle]
}
func (this *InterfaceState) AddGroupError(signature string, err string) {
this.parentGcd.GroupSendError(signature, err)
}
func (this *InterfaceState) AddMessage(m *gobjects.Message) {
this.GetContact(m.From)

View File

@ -111,7 +111,7 @@ func main() {
// these are long-lived pollers/listeners for incoming messages and status changes
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.TorStatusPoller(gcd.TorStatus, acn)
go characters.PresencePoller(gcd.UIState.GetContact, gcd.UIState.AddContact, gcd.UIState.UpdateContact)

View File

@ -23,6 +23,7 @@ RowLayout {
property alias timestamp: ts.text
property alias image: imgProfile.source
property alias status: imgProfile.status
property string error
Connections {
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
id: ack
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
sourceSize.height: 10
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
}
}
}
}