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,8 +83,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
||||||
for i := range contacts {
|
for i := range contacts {
|
||||||
contact, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
contact, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
||||||
displayName, _ := contact.GetAttribute("nick")
|
displayName, _ := contact.GetAttribute("nick")
|
||||||
deleted, _ := contact.GetAttribute("deleted")
|
|
||||||
if deleted != "deleted" {
|
|
||||||
gcd.UIState.AddContact(&gobjects.Contact{
|
gcd.UIState.AddContact(&gobjects.Contact{
|
||||||
Handle: contacts[i],
|
Handle: contacts[i],
|
||||||
DisplayName: displayName,
|
DisplayName: displayName,
|
||||||
|
@ -94,7 +93,6 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
||||||
Loading: false,
|
Loading: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
groups := the.Peer.GetGroups()
|
groups := the.Peer.GetGroups()
|
||||||
for i := range groups {
|
for i := range groups {
|
||||||
|
@ -103,10 +101,7 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
||||||
if !exists {
|
if !exists {
|
||||||
nick = group.GroupID[:12]
|
nick = group.GroupID[:12]
|
||||||
}
|
}
|
||||||
deleted, _ := group.GetAttribute("deleted")
|
|
||||||
// Only join servers for active and explicitly accepted groups.
|
// Only join servers for active and explicitly accepted groups.
|
||||||
if deleted != "deleted" {
|
|
||||||
|
|
||||||
gcd.UIState.AddContact(&gobjects.Contact{
|
gcd.UIState.AddContact(&gobjects.Contact{
|
||||||
Handle: group.GroupID,
|
Handle: group.GroupID,
|
||||||
DisplayName: nick,
|
DisplayName: nick,
|
||||||
|
@ -116,7 +111,6 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool
|
||||||
Loading: false,
|
Loading: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if e.Data[event.Status] != "running" {
|
if e.Data[event.Status] != "running" {
|
||||||
the.CwtchApp.LaunchPeers()
|
the.CwtchApp.LaunchPeers()
|
||||||
|
|
|
@ -18,9 +18,7 @@ func PresencePoller(uiState *gothings.InterfaceState) {
|
||||||
if ct == nil { // new contact has attempted to connect with us, treat it as an invite
|
if ct == nil { // new contact has attempted to connect with us, treat it as an invite
|
||||||
toc := the.Peer.GetContact(contacts[i])
|
toc := the.Peer.GetContact(contacts[i])
|
||||||
c, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
c, _ := the.Peer.GetProfile().GetContact(contacts[i])
|
||||||
deleted, _ := c.GetAttribute("deleted")
|
|
||||||
|
|
||||||
if deleted != "deleted" {
|
|
||||||
uiState.AddContact(&gobjects.Contact{
|
uiState.AddContact(&gobjects.Contact{
|
||||||
toc.Onion,
|
toc.Onion,
|
||||||
toc.Name,
|
toc.Name,
|
||||||
|
@ -40,8 +38,6 @@ func PresencePoller(uiState *gothings.InterfaceState) {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second * 4)
|
time.Sleep(time.Second * 4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ type GrandCentralDispatcher struct {
|
||||||
// contact list stuff
|
// 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:"AddContact"`
|
||||||
_ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"UpdateContact"`
|
_ func(handle, displayName, image, server string, badge, status int, trusted bool, blocked bool, loading bool) `signal:"UpdateContact"`
|
||||||
|
_ func(handle string) `signal:"RemoveContact"`
|
||||||
_ func(handle, key, value string) `signal:"UpdateContactAttribute"`
|
_ func(handle, key, value string) `signal:"UpdateContactAttribute"`
|
||||||
|
|
||||||
// messages pane stuff
|
// messages pane stuff
|
||||||
|
@ -74,6 +75,7 @@ type GrandCentralDispatcher struct {
|
||||||
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
|
_ func(onion, nick string) `signal:"savePeerSettings,auto"`
|
||||||
_ func(onion, groupID string) `signal:"inviteToGroup,auto"`
|
_ func(onion, groupID string) `signal:"inviteToGroup,auto"`
|
||||||
_ func(onion, key, nick string) `signal:"setAttribute,auto"`
|
_ func(onion, key, nick string) `signal:"setAttribute,auto"`
|
||||||
|
_ func(onion string) `signal:"deleteContact,auto""`
|
||||||
_ func(locale string) `signal:"setLocale,auto"`
|
_ func(locale string) `signal:"setLocale,auto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,13 +433,9 @@ func (this *GrandCentralDispatcher) importString(str string) {
|
||||||
|
|
||||||
checkc := the.Peer.GetContact(onion)
|
checkc := the.Peer.GetContact(onion)
|
||||||
if checkc != nil {
|
if checkc != nil {
|
||||||
deleted, _ := checkc.GetAttribute("deleted")
|
|
||||||
if deleted != "deleted" {
|
|
||||||
this.InvokePopup("already have this contact")
|
this.InvokePopup("already have this contact")
|
||||||
return //TODO: bring them to the duplicate
|
return //TODO: bring them to the duplicate
|
||||||
}
|
}
|
||||||
this.SetAttribute(onion, "deleted", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
this.UIState.AddContact(&gobjects.Contact{
|
this.UIState.AddContact(&gobjects.Contact{
|
||||||
Handle: onion,
|
Handle: onion,
|
||||||
|
@ -484,7 +482,6 @@ func (this *GrandCentralDispatcher) createGroup(server, groupName string) {
|
||||||
the.Peer.JoinServer(server)
|
the.Peer.JoinServer(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) blockPeer(onion string) {
|
func (this *GrandCentralDispatcher) blockPeer(onion string) {
|
||||||
err := the.Peer.BlockPeer(onion)
|
err := the.Peer.BlockPeer(onion)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -502,7 +499,6 @@ func (this *GrandCentralDispatcher) unblockPeer(onion string) {
|
||||||
this.UIState.UpdateContact(onion)
|
this.UIState.UpdateContact(onion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
||||||
err := the.Peer.InviteOnionToGroup(onion, groupID)
|
err := the.Peer.InviteOnionToGroup(onion, groupID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -511,12 +507,13 @@ func (this *GrandCentralDispatcher) inviteToGroup(onion, groupID string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) leaveGroup(groupID string) {
|
func (this *GrandCentralDispatcher) leaveGroup(groupID string) {
|
||||||
the.EventBus.Publish(event.NewEvent(event.SetGroupAttribute, map[event.Field]string{
|
the.Peer.DeleteGroup(groupID)
|
||||||
event.GroupID: groupID,
|
this.RemoveContact(groupID)
|
||||||
event.Key: "deleted",
|
}
|
||||||
event.Data: "deleted",
|
|
||||||
}))
|
func (this *GrandCentralDispatcher) deleteContact(onion string) {
|
||||||
this.UIState.UpdateContactAttribute(groupID, "deleted", "deleted")
|
the.Peer.DeleteContact(onion)
|
||||||
|
this.RemoveContact(onion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *GrandCentralDispatcher) acceptGroup(groupID string) {
|
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 {
|
func (this *InterfaceState) GetContact(handle string) *gobjects.Contact {
|
||||||
if _, found := this.contacts.Load(handle); !found {
|
if _, found := this.contacts.Load(handle); !found {
|
||||||
if len(handle) == 32 {
|
if len(handle) == 32 {
|
||||||
|
|
|
@ -99,7 +99,7 @@ ColumnLayout { // peerSettingsPane
|
||||||
text: qsTr("delete-btn")
|
text: qsTr("delete-btn")
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
gcd.setAttribute(txtOnion.text, "deleted", "deleted")
|
gcd.deleteContact(txtOnion.text)
|
||||||
theStack.pane = theStack.emptyPane
|
theStack.pane = theStack.emptyPane
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,24 +57,22 @@ ColumnLayout {
|
||||||
"_status": status,
|
"_status": status,
|
||||||
"_trusted": trusted,
|
"_trusted": trusted,
|
||||||
"_blocked": blocked,
|
"_blocked": blocked,
|
||||||
"_deleted": false,
|
|
||||||
"_loading": loading,
|
"_loading": loading,
|
||||||
|
"_loading": loading
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateContactAttribute: function(handle, key, value) {
|
onRemoveContact: function(handle) {
|
||||||
if (key == "deleted" && value == "deleted") {
|
|
||||||
for(var i = 0; i < contactsModel.count; i++){
|
for(var i = 0; i < contactsModel.count; i++){
|
||||||
if(contactsModel.get(i)["_handle"] == handle) {
|
if(contactsModel.get(i)["_handle"] == handle) {
|
||||||
console.log("deleting contact " + contactsModel.get(i).handle)
|
console.log("deleting contact " + contactsModel.get(i)["_handle"])
|
||||||
contactsModel.get(i)._deleted = true
|
contactsModel.remove(i)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ListModel { // CONTACT OBJECTS ARE STORED HERE ...
|
ListModel { // CONTACT OBJECTS ARE STORED HERE ...
|
||||||
id: contactsModel
|
id: contactsModel
|
||||||
}
|
}
|
||||||
|
@ -90,7 +88,6 @@ ColumnLayout {
|
||||||
status: _status
|
status: _status
|
||||||
trusted: _trusted
|
trusted: _trusted
|
||||||
blocked: _blocked
|
blocked: _blocked
|
||||||
deleted: _deleted
|
|
||||||
loading: _loading
|
loading: _loading
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import QtQuick.Controls.Styles 1.4
|
||||||
Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
visible: !deleted
|
|
||||||
height: 48 * logscale + 3
|
height: 48 * logscale + 3
|
||||||
implicitHeight: height
|
implicitHeight: height
|
||||||
|
|
||||||
|
@ -25,7 +24,6 @@ Item { // LOTS OF NESTING TO DEAL WITH QT WEIRDNESS, SORRY
|
||||||
property bool isHover
|
property bool isHover
|
||||||
property bool trusted
|
property bool trusted
|
||||||
property bool blocked
|
property bool blocked
|
||||||
property bool deleted
|
|
||||||
property bool loading
|
property bool loading
|
||||||
property alias status: imgProfile.status
|
property alias status: imgProfile.status
|
||||||
property string server
|
property string server
|
||||||
|
|
Reference in New Issue