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

This commit is contained in:
Dan Ballard 2019-03-04 22:20:30 +00:00 committed by Gogs
commit 7b350d4c54
5 changed files with 41 additions and 54 deletions

View File

@ -17,6 +17,7 @@ func IncomingListener(callback func(*gobjects.Message), groupErrorCallback func(
the.CwtchApp.EventBus().Subscribe(event.NewMessageFromGroup, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.NewGroupInvite, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.SendMessageToGroupError, q.EventChannel)
the.CwtchApp.EventBus().Subscribe(event.SendMessageToPeerError, q.EventChannel)
for {
e := q.Next()
@ -68,6 +69,8 @@ func IncomingListener(callback func(*gobjects.Message), groupErrorCallback func(
log.Debugf("got a group invite!")
case event.SendMessageToGroupError:
groupErrorCallback(e.Data[event.Signature], e.Data[event.Error])
case event.SendMessageToPeerError:
groupErrorCallback(e.Data[event.Signature], e.Data[event.Error])
}
}
}

View File

@ -1,36 +0,0 @@
package characters
import (
"cwtch.im/ui/go/gobjects"
"cwtch.im/ui/go/the"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
)
func PostmanPat(messages chan gobjects.Letter) {
postOffice := make(map[string]chan gobjects.Letter)
for {
m := <-messages
_, found := postOffice[m.To]
if !found {
postOffice[m.To] = make(chan gobjects.Letter, 100)
go andHisBlackAndWhiteCat(postOffice[m.To])
}
postOffice[m.To] <- m
}
}
func andHisBlackAndWhiteCat(incomingMessages chan gobjects.Letter) {
for {
m := <-incomingMessages
the.Peer.PeerWithOnion(m.To)
log.Debugf("sending message!")
ackID := new(the.AckId)
ackID.ID = m.MID
ackID.Ack = false
the.AcknowledgementIDs[m.To] = append(the.AcknowledgementIDs[m.To], ackID)
the.Peer.SendMessageToPeer(m.To, m.Message)
}
}

View File

@ -88,6 +88,19 @@ func (this *GrandCentralDispatcher) sendMessage(message string, mID string) {
var err error
mID,err = the.Peer.SendMessageToGroupTracked(this.CurrentOpenConversation(), message)
this.UIState.AddMessage(&gobjects.Message{
this.CurrentOpenConversation(),
"me",
"",
message,
"",
true,
mID,
time.Now(),
false,
})
if err != nil {
this.InvokePopup("failed to send message " +err.Error())
return
@ -100,24 +113,29 @@ func (this *GrandCentralDispatcher) sendMessage(message string, mID string) {
this.UIState.UpdateContact(this.CurrentOpenConversation())
}
select { // 1 weird trick to do a non-blocking send. this means the user can only send a limited number of messages
// before the channel buffer fills. TODO: stop the user from sending if the buffer is full
case this.OutgoingMessages <- gobjects.Letter{this.CurrentOpenConversation(), message, mID}:
default:
}
to := this.CurrentOpenConversation();
the.Peer.PeerWithOnion(to)
mID = the.Peer.SendMessageToPeer(to, message)
this.UIState.AddMessage(&gobjects.Message{
this.CurrentOpenConversation(),
"me",
"",
message,
"",
true,
mID,
time.Now(),
false,
})
ackID := new(the.AckId)
ackID.ID = mID
ackID.Ack = false
the.AcknowledgementIDs[to] = append(the.AcknowledgementIDs[to], ackID)
}
this.UIState.AddMessage(&gobjects.Message{
this.CurrentOpenConversation(),
"me",
"",
message,
"",
true,
mID,
time.Now(),
false,
})
}
func (this *GrandCentralDispatcher) loadMessagesPane(handle string) {

View File

@ -112,7 +112,6 @@ func main() {
// these are long-lived pollers/listeners for incoming messages and status changes
loadCwtchData(gcd, acn)
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)
go characters.GroupPoller(gcd.UIState.GetContact, gcd.UIState.UpdateContact)
@ -208,7 +207,9 @@ func loadCwtchData(gcd *gothings.GrandCentralDispatcher, acn connectivity.ACN) {
})
}
if group.Accepted {
// Only send a join server packet if we haven't joined this server yet...
_,connecting := the.Peer.GetServers()[group.GroupServer]
if group.Accepted && !connecting {
the.Peer.JoinServer(group.GroupServer)
}
}

View File

@ -35,6 +35,7 @@ RowLayout {
}
onGroupSendError: function(mid, error) {
console.log("Error " + mid + " " + messageID)
if (mid == messageID) {
root.error = error
}