Merge branch 'textfix' of cwtch.im/ui into master

This commit is contained in:
erinn 2019-02-13 03:13:48 +00:00 committed by Gogs
commit 01a473175b
4 changed files with 42 additions and 53 deletions

View File

@ -15,7 +15,8 @@ func GroupPoller(getContact func(string) *gobjects.Contact, updateContact func(s
groups := the.Peer.GetGroups()
for i := range groups {
group := the.Peer.GetGroup(groups[i])
if group != nil {
if group != nil && group.GroupID != "" {
log.Debugf("Found a Group: %v %v", group.GroupID, group.GroupServer)
getContact(group.GroupID).Status = int(servers[group.GroupServer])
updateContact(group.GroupID)
} else {

View File

@ -4,6 +4,7 @@ import (
"encoding/base32"
"encoding/hex"
"fmt"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"strings"
)
@ -12,7 +13,8 @@ func RandomProfileImage(onion string) string {
choices := []string{"001-centaur", "002-kraken", "003-dinosaur", "004-tree-1", "005-hand", "006-echidna", "007-robot", "008-mushroom", "009-harpy", "010-phoenix", "011-dragon-1", "012-devil", "013-troll", "014-alien", "015-minotaur", "016-madre-monte", "017-satyr", "018-karakasakozou", "019-pirate", "020-werewolf", "021-scarecrow", "022-valkyrie", "023-curupira", "024-loch-ness-monster", "025-tree", "026-cerberus", "027-gryphon", "028-mermaid", "029-vampire", "030-goblin", "031-yeti", "032-leprechaun", "033-medusa", "034-chimera", "035-elf", "036-hydra", "037-cyclops", "038-pegasus", "039-narwhal", "040-woodcutter", "041-zombie", "042-dragon", "043-frankenstein", "044-witch", "045-fairy", "046-genie", "047-pinocchio", "048-ghost", "049-wizard", "050-unicorn"}
barr, err := base32.StdEncoding.DecodeString(strings.ToUpper(onion))
if err != nil || len(barr) != 35 {
fmt.Printf("error: %v %v %v\n", onion, err, barr)
log.Errorf("error: %v %v %v\n", onion, err, barr)
panic("lol")
return "qrc:/qml/images/extra/openprivacy.png"
}
return "qrc:/qml/images/profiles/" + choices[int(barr[33])%len(choices)] + ".png"

View File

@ -10,7 +10,6 @@ import (
"cwtch.im/ui/go/gobjects"
"cwtch.im/ui/go/the"
"encoding/base32"
"fmt"
"github.com/therecipe/qt/core"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"strings"
@ -165,11 +164,13 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) {
} // ELSE LOAD CONTACT
contact, _ := the.Peer.GetProfile().GetContact(handle)
nick,_ := contact.GetAttribute("nick")
if nick == "" {
this.SetToolbarTitle(handle)
} else {
this.SetToolbarTitle(nick)
if contact != nil {
nick, _ := contact.GetAttribute("nick")
if nick == "" {
this.SetToolbarTitle(handle)
} else {
this.SetToolbarTitle(nick)
}
}
messages := this.UIState.GetMessages(handle)
@ -298,33 +299,11 @@ func (this *GrandCentralDispatcher) importString(str string) {
//eg: torv3JFDWkXExBsZLkjvfkkuAxHsiLGZBk0bvoeJID9ItYnU=EsEBCiBhOWJhZDU1OTQ0NWI3YmM2N2YxYTM5YjkzMTNmNTczNRIgpHeNaG+6jy750eDhwLO39UX4f2xs0irK/M3P6mDSYQIaOTJjM2ttb29ibnlnaGoyenc2cHd2N2Q1N3l6bGQ3NTNhdW8zdWdhdWV6enB2ZmFrM2FoYzRiZHlkCiJAdVSSVgsksceIfHe41OJu9ZFHO8Kwv3G6F5OK3Hw4qZ6hn6SiZjtmJlJezoBH0voZlCahOU7jCOg+dsENndZxAA==
if str[0:5] == "torv3" { // GROUP INVITE
groupID, err := the.Peer.ImportGroup(str)
_, err := the.Peer.ImportGroup(str)
if err != nil {
this.InvokePopup("not a valid group invite")
return
}
group := the.Peer.GetGroup(groupID)
log.Debugf("group id: %s", groupID)
if group == nil {
log.Debugf("group IS nil. bad!")
} else {
log.Debugf("group is NOT nil. good!")
}
the.Peer.JoinServer(group.GroupServer)
this.UIState.AddContact(&gobjects.Contact{
groupID,
groupID[:12],
cwutil.RandomGroupImage(groupID),
group.GroupServer,
0,
0,
true,
})
fmt.Printf("imported groupid=%s server=%s", groupID, group.GroupServer)
return
}

View File

@ -24,13 +24,10 @@ func NewUIState(gcd *GrandCentralDispatcher) (uis InterfaceState) {
func (this *InterfaceState) AddContact(c *gobjects.Contact) {
if len(c.Handle) == 32 { // ADD GROUP
//TODO: we should handle group creation here too probably? the code for groups vs individuals is weird right now ^ea
if _, found := this.contacts[c.Handle]; !found {
this.contacts[c.Handle] = c
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
this.contacts[c.Handle] = c
}
return
} else if len(c.Handle) != 56 {
log.Errorf("sorry, unable to handle AddContact(%v)", c.Handle)
@ -38,33 +35,43 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
return
}
if the.Peer.GetContact(c.Handle) == nil {
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(c.Handle))
the.Peer.AddContact(c.DisplayName, c.Handle, decodedPub, c.Trusted)
go the.Peer.PeerWithOnion(c.Handle)
}
if _, found := this.contacts[c.Handle]; !found {
this.contacts[c.Handle] = c
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
if the.Peer.GetContact(c.Handle) == nil {
decodedPub, _ := base32.StdEncoding.DecodeString(strings.ToUpper(c.Handle))
the.Peer.AddContact(c.DisplayName, c.Handle, decodedPub, c.Trusted)
go the.Peer.PeerWithOnion(c.Handle)
}
}
}
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
if _, found := this.contacts[handle]; !found {
c := &gobjects.Contact{
handle,
handle,
cwutil.RandomProfileImage(handle),
"",
1,
0,
false,
if len(handle) == 32 {
this.AddContact(&gobjects.Contact{
handle,
handle,
cwutil.RandomGroupImage(handle),
"",
0,
0,
false,
})
group := the.Peer.GetGroup(handle)
go the.Peer.JoinServer(group.GroupServer)
} else {
this.AddContact(&gobjects.Contact{
handle,
handle,
cwutil.RandomProfileImage(handle),
"",
0,
0,
false,
})
go the.Peer.PeerWithOnion(handle)
}
this.contacts[handle] = c
this.parentGcd.AddContact(c.Handle, c.DisplayName, c.Image, c.Server, c.Badge, c.Status, c.Trusted)
go the.Peer.PeerWithOnion(c.Handle)
}
return this.contacts[handle]