removing fake delete to surface fake deleted contact as we still connect to them; adopting proper delete support added to cwtch
This commit is contained in:
parent
6de3805ecf
commit
12fde77c71
|
@ -83,17 +83,15 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
|||
for i := range contacts {
|
||||
contact, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
||||
displayName, _ := contact.GetAttribute("nick")
|
||||
deleted, _ := contact.GetAttribute("deleted")
|
||||
if deleted != "deleted" {
|
||||
gcd.UIState.AddContact(&gobjects.Contact{
|
||||
Handle: contacts[i],
|
||||
DisplayName: displayName,
|
||||
Image: cwutil.RandomProfileImage(contacts[i]),
|
||||
Trusted: contact.Trusted,
|
||||
Blocked: contact.Blocked,
|
||||
Loading: false,
|
||||
})
|
||||
}
|
||||
|
||||
gcd.UIState.AddContact(&gobjects.Contact{
|
||||
Handle: contacts[i],
|
||||
DisplayName: displayName,
|
||||
Image: cwutil.RandomProfileImage(contacts[i]),
|
||||
Trusted: contact.Trusted,
|
||||
Blocked: contact.Blocked,
|
||||
Loading: false,
|
||||
})
|
||||
}
|
||||
|
||||
groups := the.Peer.GetGroups()
|
||||
|
@ -103,19 +101,15 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
|||
if !exists {
|
||||
nick = group.GroupID[:12]
|
||||
}
|
||||
deleted, _ := group.GetAttribute("deleted")
|
||||
// Only join servers for active and explicitly accepted groups.
|
||||
if deleted != "deleted" {
|
||||
|
||||
gcd.UIState.AddContact(&gobjects.Contact{
|
||||
Handle: group.GroupID,
|
||||
DisplayName: nick,
|
||||
Image: cwutil.RandomGroupImage(group.GroupID),
|
||||
Server: group.GroupServer,
|
||||
Trusted: group.Accepted,
|
||||
Loading: false,
|
||||
})
|
||||
}
|
||||
gcd.UIState.AddContact(&gobjects.Contact{
|
||||
Handle: group.GroupID,
|
||||
DisplayName: nick,
|
||||
Image: cwutil.RandomGroupImage(group.GroupID),
|
||||
Server: group.GroupServer,
|
||||
Trusted: group.Accepted,
|
||||
Loading: false,
|
||||
})
|
||||
}
|
||||
|
||||
if e.Data[event.Status] != "running" {
|
||||
|
|
|
@ -18,29 +18,25 @@ func PresencePoller(uiState *gothings.InterfaceState) {
|
|||
if ct == nil { // new contact has attempted to connect with us, treat it as an invite
|
||||
toc := the.Peer.GetContact(contacts[i])
|
||||
c, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
||||
deleted, _ := c.GetAttribute("deleted")
|
||||
|
||||
if deleted != "deleted" {
|
||||
uiState.AddContact(&gobjects.Contact{
|
||||
toc.Onion,
|
||||
toc.Name,
|
||||
cwutil.RandomProfileImage(toc.Onion),
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
c.Trusted,
|
||||
c.Blocked,
|
||||
false,
|
||||
})
|
||||
uiState.AddContact(&gobjects.Contact{
|
||||
toc.Onion,
|
||||
toc.Name,
|
||||
cwutil.RandomProfileImage(toc.Onion),
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
c.Trusted,
|
||||
c.Blocked,
|
||||
false,
|
||||
})
|
||||
|
||||
the.EventBus.Publish(event.NewEvent(event.SetPeerAttribute, map[event.Field]string{
|
||||
event.RemotePeer: contacts[i],
|
||||
event.Key: "name",
|
||||
event.Data: c.Name,
|
||||
}))
|
||||
}
|
||||
the.EventBus.Publish(event.NewEvent(event.SetPeerAttribute, map[event.Field]string{
|
||||
event.RemotePeer: contacts[i],
|
||||
event.Key: "name",
|
||||
event.Data: c.Name,
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
time.Sleep(time.Second * 4)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ type GrandCentralDispatcher struct {
|
|||
// contact list stuff
|
||||
_ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"AddContact"`
|
||||
_ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"UpdateContact"`
|
||||
_ func(handle, key, value string) `signal:"UpdateContactAttribute"`
|
||||
_ func(handle string) `signal:"RemoveContact"`
|
||||
_ func(handle, key, value string) `signal:"UpdateContactAttribute"`
|
||||
|
||||
// messages pane stuff
|
||||
_ func(handle, from, displayName, message, image string, mID string, fromMe bool, ts string, ackd bool, error bool) `signal:"AppendMessage"`
|
||||
|
@ -52,7 +53,7 @@ type GrandCentralDispatcher struct {
|
|||
_ func(str string) `signal:"InvokePopup"`
|
||||
_ func(zoom, locale string) `signal:"SupplySettings"`
|
||||
_ func(groupID, name, server, invitation string, accepted bool, addrbooknames, addrbookaddrs []string) `signal:"SupplyGroupSettings"`
|
||||
_ func(onion, nick string, blocked bool) `signal:"SupplyPeerSettings"`
|
||||
_ func(onion, nick string, blocked bool) `signal:"SupplyPeerSettings"`
|
||||
|
||||
// signals emitted from the ui (written in go, below)
|
||||
_ func(message string, mid string) `signal:"sendMessage,auto"`
|
||||
|
@ -74,6 +75,7 @@ type GrandCentralDispatcher struct {
|
|||
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
|
||||
_ func(onion, groupID string) `signal:"inviteToGroup,auto"`
|
||||
_ func(onion, key, nick string) `signal:"setAttribute,auto"`
|
||||
_ func(onion string) `signal:"deleteContact,auto""`
|
||||
_ func(locale string) `signal:"setLocale,auto"`
|
||||
}
|
||||
|
||||
|
@ -431,12 +433,8 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
|||
|
||||
checkc := the.Peer.GetContact(onion)
|
||||
if checkc != nil {
|
||||
deleted, _ := checkc.GetAttribute("deleted")
|
||||
if deleted != "deleted" {
|
||||
this.InvokePopup("already have this contact")
|
||||
return //TODO: bring them to the duplicate
|
||||
}
|
||||
this.SetAttribute(onion, "deleted", "")
|
||||
this.InvokePopup("already have this contact")
|
||||
return //TODO: bring them to the duplicate
|
||||
}
|
||||
|
||||
this.UIState.AddContact(&gobjects.Contact{
|
||||
|
@ -484,7 +482,6 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
|||
the.Peer.JoinServer(server)
|
||||
}
|
||||
|
||||
|
||||
func (this *GrandCentralDispatcher) blockPeer(onion string) {
|
||||
err := the.Peer.BlockPeer(onion)
|
||||
if err != nil {
|
||||
|
@ -502,7 +499,6 @@ func (this *GrandCentralDispatcher) unblockPeer(onion string) {
|
|||
this.UIState.UpdateContact(onion)
|
||||
}
|
||||
|
||||
|
||||
func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
||||
err := the.Peer.InviteOnionToGroup(onion, groupID)
|
||||
if err != nil {
|
||||
|
@ -511,12 +507,13 @@ func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
|||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) leaveGroup(groupID string) {
|
||||
the.EventBus.Publish(event.NewEvent(event.SetGroupAttribute, map[event.Field]string{
|
||||
event.GroupID: groupID,
|
||||
event.Key: "deleted",
|
||||
event.Data: "deleted",
|
||||
}))
|
||||
this.UIState.UpdateContactAttribute(groupID, "deleted", "deleted")
|
||||
the.Peer.DeleteGroup(groupID)
|
||||
this.RemoveContact(groupID)
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) deleteContact(onion string) {
|
||||
the.Peer.DeleteContact(onion)
|
||||
this.RemoveContact(onion)
|
||||
}
|
||||
|
||||
func (this *GrandCentralDispatcher) acceptGroup(groupID string) {
|
||||
|
|
|
@ -49,6 +49,10 @@ func (this *InterfaceState) AddContact(c *gobjects.Contact) {
|
|||
}
|
||||
}
|
||||
|
||||
func (this *InterfaceState) DeleteContact(id string) {
|
||||
this.contacts.Delete(id)
|
||||
}
|
||||
|
||||
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||
if _, found := this.contacts.Load(handle); !found {
|
||||
if len(handle) == 32 {
|
||||
|
|
|
@ -99,7 +99,7 @@ ColumnLayout { // peerSettingsPane
|
|||
text: qsTr("delete-btn")
|
||||
|
||||
onClicked: {
|
||||
gcd.setAttribute(txtOnion.text, "deleted", "deleted")
|
||||
gcd.deleteContact(txtOnion.text)
|
||||
theStack.pane = theStack.emptyPane
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,22 +57,20 @@ ColumnLayout {
|
|||
"_status": status,
|
||||
"_trusted": trusted,
|
||||
"_blocked": blocked,
|
||||
"_deleted": false,
|
||||
"_loading": loading,
|
||||
"_loading": loading
|
||||
})
|
||||
}
|
||||
|
||||
onUpdateContactAttribute: function(handle, key, value) {
|
||||
if (key == "deleted" && value == "deleted") {
|
||||
for(var i = 0; i<contactsModel.count;i++){
|
||||
if(contactsModel.get(i)["_handle"] == handle) {
|
||||
console.log("deleting contact " + contactsModel.get(i).handle)
|
||||
contactsModel.get(i)._deleted = true
|
||||
}
|
||||
}
|
||||
}
|
||||
onRemoveContact: function(handle) {
|
||||
for(var i = 0; i < contactsModel.count; i++){
|
||||
if(contactsModel.get(i)["_handle"] == handle) {
|
||||
console.log("deleting contact " + contactsModel.get(i)["_handle"])
|
||||
contactsModel.remove(i)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ListModel { // CONTACT OBJECTS ARE STORED HERE ...
|
||||
|
@ -90,7 +88,6 @@ ColumnLayout {
|
|||
status: _status
|
||||
trusted: _trusted
|
||||
blocked: _blocked
|
||||
deleted: _deleted
|
||||
loading: _loading
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import QtQuick.Controls.Styles 1.4
|
|||
Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
visible: !deleted
|
||||
height: 48 * logscale + 3
|
||||
implicitHeight: height
|
||||
|
||||
|
@ -25,7 +24,6 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
|||
property bool isHover
|
||||
property bool trusted
|
||||
property bool blocked
|
||||
property bool deleted
|
||||
property bool loading
|
||||
property alias status: imgProfile.status
|
||||
property string server
|
||||
|
|
Reference in New Issue