aboutsummaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
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;
}
}