aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-04-16 11:44:14 +0200
committerfiaxh <git@lightrise.org>2019-04-16 12:32:28 +0200
commitb0dde02bc9e5ff29025ff5fc70fd46d56df5d2ec (patch)
tree906a531f68989d7d2cdf03201b8dfc9ebd4265ce /main/src
parentca9b00d5e8e494ec46bc28259a104ade3adaa40c (diff)
downloaddino-b0dde02bc9e5ff29025ff5fc70fd46d56df5d2ec.tar.gz
dino-b0dde02bc9e5ff29025ff5fc70fd46d56df5d2ec.zip
Order MUC occupants tab completion by most recent message sent
fixes #401
Diffstat (limited to 'main/src')
-rw-r--r--main/src/ui/chat_input/occupants_tab_completer.vala25
1 files changed, 22 insertions, 3 deletions
diff --git a/main/src/ui/chat_input/occupants_tab_completer.vala b/main/src/ui/chat_input/occupants_tab_completer.vala
index fb9b2377..57d7e91d 100644
--- a/main/src/ui/chat_input/occupants_tab_completer.vala
+++ b/main/src/ui/chat_input/occupants_tab_completer.vala
@@ -101,15 +101,34 @@ class OccupantsTabCompletor {
private Gee.List<string> generate_completions_from_occupants(string prefix) {
Gee.List<string> ret = new ArrayList<string>();
+
+ // First suggest nicks that have recently writen something
+ Gee.List<Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation, 50);
+ for (int i = messages.size - 1; i > 0; i--) {
+ string resourcepart = messages[i].from.resourcepart;
+ Jid? own_nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
+ if (resourcepart != null && resourcepart != "" &&
+ resourcepart.to_string().down().has_prefix(prefix.down()) &&
+ (own_nick == null || resourcepart != own_nick.resourcepart) &&
+ !ret.contains(resourcepart)) {
+ ret.add(resourcepart.to_string());
+ }
+ }
+
+ // Then, suggest other nicks in alphabetical order
Gee.List<Jid>? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_other_occupants(conversation.counterpart, conversation.account);
+ Gee.List<string> filtered_occupants = new ArrayList<string>();
if (occupants != null) {
foreach (Jid jid in occupants) {
- if (jid.resourcepart.to_string().down().has_prefix(prefix.down())) {
- ret.add(jid.resourcepart.to_string());
+ string resourcepart = jid.resourcepart.to_string();
+ if (resourcepart.down().has_prefix(prefix.down()) && !ret.contains(resourcepart)) {
+ filtered_occupants.add(resourcepart);
}
}
}
- ret.sort();
+ filtered_occupants.sort();
+
+ ret.add_all(filtered_occupants);
return ret;
}
}