From a81af020f30bfda4dec60a52aec142a0c5abb297 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Thu, 20 Feb 2020 16:29:23 +0100 Subject: Preserve unchanged conference data (name) in bookmarks fixes #748 --- xmpp-vala/src/module/xep/0048_bookmarks.vala | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'xmpp-vala/src/module/xep/0048_bookmarks.vala') diff --git a/xmpp-vala/src/module/xep/0048_bookmarks.vala b/xmpp-vala/src/module/xep/0048_bookmarks.vala index 2fd38bea..daacf1a4 100644 --- a/xmpp-vala/src/module/xep/0048_bookmarks.vala +++ b/xmpp-vala/src/module/xep/0048_bookmarks.vala @@ -7,7 +7,7 @@ public class Module : BookmarksProvider, XmppStreamModule { public static ModuleIdentity IDENTITY = new ModuleIdentity(NS_URI, "0048_bookmarks_module"); public async Set? get_conferences(XmppStream stream) { - Set ret = new HashSet(Conference.hash_func, Conference.equal_func); + Set ret = new HashSet(Conference.hash_func, Conference.equals_func); StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns(); stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node) => { @@ -54,20 +54,26 @@ public class Module : BookmarksProvider, XmppStreamModule { public async void add_conference(XmppStream stream, Conference conference) { Set? conferences = yield get_conferences(stream); conferences.add(conference); - stream.get_module(Module.IDENTITY).set_conferences(stream, conferences); + set_conferences(stream, conferences); } - public async void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference) { + public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) { Set? conferences = yield get_conferences(stream); - conferences.remove(orig_conference); - conferences.add(modified_conference); - stream.get_module(Module.IDENTITY).set_conferences(stream, conferences); + foreach (Conference conference in conferences) { + if (conference.jid.equals(muc_jid)) { + conference.autojoin = modified_conference.autojoin; + conference.name = modified_conference.name; + conference.nick = modified_conference.nick; + conference.password = modified_conference.password; + } + } + set_conferences(stream, conferences); } public async void remove_conference(XmppStream stream, Conference conference_remove) { Set? conferences = yield get_conferences(stream); conferences.remove(conference_remove); - stream.get_module(Module.IDENTITY).set_conferences(stream, conferences); + set_conferences(stream, conferences); } public override void attach(XmppStream stream) { } -- cgit v1.2.3-70-g09d2