aboutsummaryrefslogtreecommitdiff
path: root/libdino
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-01-17 20:48:29 +0100
committerfiaxh <git@lightrise.org>2020-01-17 20:48:29 +0100
commit4c3800c688f87482cdf79c4ecb1c7764ff01e213 (patch)
treeab75850152b61e19ca8025303cb10a62dc5e0fd4 /libdino
parent7f21f898e0ec6efe5a8cf66053150e9a20ade53e (diff)
downloaddino-4c3800c688f87482cdf79c4ecb1c7764ff01e213.tar.gz
dino-4c3800c688f87482cdf79c4ecb1c7764ff01e213.zip
Deactivate MUC conversations with non-autojoin bookmarks
Diffstat (limited to 'libdino')
-rw-r--r--libdino/src/service/muc_manager.vala46
1 files changed, 23 insertions, 23 deletions
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index ab461701..0e27b724 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -308,11 +308,11 @@ public class MucManager : StreamInteractionModule, Object {
bookmarks_updated(account, conferences);
});
bookmarks_provider[account].conference_added.connect( (stream, conference) => {
- sync_autojoin_state(account, conference.jid, conference);
+ // TODO join (for Bookmarks2)
conference_added(account, conference);
});
bookmarks_provider[account].conference_removed.connect( (stream, jid) => {
- sync_autojoin_state(account, jid, null);
+ // TODO part (for Bookmarks2)
conference_removed(account, jid);
});
}
@@ -339,35 +339,35 @@ public class MucManager : StreamInteractionModule, Object {
}
private void sync_autojoin_active(Account account, Set<Conference> conferences) {
- Gee.List<Conversation> conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account);
- foreach (Conference conference in conferences) {
- sync_autojoin_state(account, conference.jid, conference, conversations);
- }
- }
+ Gee.List<Conversation> active_conversations = stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account);
- private void sync_autojoin_state(Account account, Jid jid, Conference? conference, Gee.List<Conversation>? conversations_ = null) {
- Gee.List<Conversation> conversations = conversations_ ?? stream_interactor.get_module(ConversationManager.IDENTITY).get_active_conversations(account);
+ // Join auto-join MUCs
+ foreach (Conference conference in conferences) {
+ if (!conference.autojoin) continue;
- if (conference != null && conference.autojoin) {
- // Join if we should join
bool is_active = false;
- foreach (Conversation conversation in conversations) {
- if (conference.jid.equals(conversation.counterpart)) is_active = true;
+ foreach (Conversation conversation in active_conversations) {
+ if (conference.jid.equals(conversation.counterpart)) {
+ is_active = true;
+ }
}
- if (!is_active || !is_joined(jid, account)) {
+ if (!is_active || !is_joined(conference.jid, account)) {
join.begin(account, conference.jid, conference.nick, conference.password);
}
- } else {
- // Leave if we should leave
- bool is_active = false;
- foreach (Conversation conversation in conversations) {
- if (conversation.type_ != Conversation.Type.GROUPCHAT || !conversation.account.equals(account)) continue;
- if (jid.equals(conversation.counterpart)) {
- is_active = true;
+ }
+
+ // Part MUCs that aren't auto-join (which closes those conversations)
+ foreach (Conversation conversation in active_conversations) {
+ if (conversation.type_ != Conversation.Type.GROUPCHAT) continue;
+
+ bool should_be_active = false;
+ foreach (Conference conference in conferences) {
+ if (conference.jid.equals(conversation.counterpart) && conference.autojoin) {
+ should_be_active = true;
}
}
- if (is_active) {
- part(account, jid);
+ if (!should_be_active) {
+ part(conversation.account, conversation.counterpart);
}
}
}