diff --git a/go/characters/appEventListener.go b/go/characters/appEventListener.go index e9d9d65b..4aa1611d 100644 --- a/go/characters/appEventListener.go +++ b/go/characters/appEventListener.go @@ -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" { diff --git a/go/characters/presencepoller.go b/go/characters/presencepoller.go index a4c26bfb..9c7a91e1 100644 --- a/go/characters/presencepoller.go +++ b/go/characters/presencepoller.go @@ -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) } diff --git a/go/gothings/gcd.go b/go/gothings/gcd.go index 8fbf5aa1..3b8a724b 100644 --- a/go/gothings/gcd.go +++ b/go/gothings/gcd.go @@ -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) { diff --git a/go/gothings/uistate.go b/go/gothings/uistate.go index d2977884..8f55c800 100644 --- a/go/gothings/uistate.go +++ b/go/gothings/uistate.go @@ -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 { diff --git a/qml/panes/PeerSettingsPane.qml b/qml/panes/PeerSettingsPane.qml index 3fa3c419..a48b8f02 100644 --- a/qml/panes/PeerSettingsPane.qml +++ b/qml/panes/PeerSettingsPane.qml @@ -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 } } diff --git a/qml/widgets/ContactList.qml b/qml/widgets/ContactList.qml index 8390d986..d13fdd3d 100644 --- a/qml/widgets/ContactList.qml +++ b/qml/widgets/ContactList.qml @@ -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