aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/chat_input
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-05-28 01:52:12 +0200
committerfiaxh <git@lightrise.org>2020-06-03 21:50:40 +0200
commita9e6a9c3d58002810757f1e3f4fc9c9488b48fc4 (patch)
tree90dc67f65bbf48c3c6ddef72d5c623a91f657a5e /main/src/ui/chat_input
parentd01af5b520d112b00e4c18b16657f89d5afe7ad4 (diff)
downloaddino-a9e6a9c3d58002810757f1e3f4fc9c9488b48fc4.tar.gz
dino-a9e6a9c3d58002810757f1e3f4fc9c9488b48fc4.zip
Code cleanup
Diffstat (limited to 'main/src/ui/chat_input')
-rw-r--r--main/src/ui/chat_input/occupants_tab_completer.vala23
1 files changed, 6 insertions, 17 deletions
diff --git a/main/src/ui/chat_input/occupants_tab_completer.vala b/main/src/ui/chat_input/occupants_tab_completer.vala
index ab1b75e0..6d2a7434 100644
--- a/main/src/ui/chat_input/occupants_tab_completer.vala
+++ b/main/src/ui/chat_input/occupants_tab_completer.vala
@@ -86,13 +86,14 @@ public class OccupantsTabCompletor {
}
}
- private Gee.List<string> generate_completions_from_messages() {
+ private Gee.List<string> generate_completions_from_messages(string? prefix = null) {
Gee.List<string> ret = new ArrayList<string>();
- Gee.List<Message> messages = stream_interactor.get_module(MessageStorage.IDENTITY).get_messages(conversation, 10);
- for (int i = messages.size - 1; i > 0; i--) {
- string resourcepart = messages[i].from.resourcepart;
+ Gee.List<ContentItem> content_items = stream_interactor.get_module(ContentItemStore.IDENTITY).get_n_latest(conversation, 10);
+ for (int i = content_items.size - 1; i > 0; i--) {
+ string resourcepart = content_items[i].jid.resourcepart;
Jid? own_nick = stream_interactor.get_module(MucManager.IDENTITY).get_own_jid(conversation.counterpart, conversation.account);
if (resourcepart != null && resourcepart != "" && (own_nick == null || resourcepart != own_nick.resourcepart) && !ret.contains(resourcepart)) {
+ if (prefix != null && !resourcepart.to_string().down().has_prefix(prefix.down())) continue;
ret.add(resourcepart);
}
}
@@ -100,20 +101,8 @@ public 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());
- }
- }
+ Gee.List<string> ret = generate_completions_from_messages(prefix);
// Then, suggest other nicks in alphabetical order
Gee.List<Jid>? occupants = stream_interactor.get_module(MucManager.IDENTITY).get_other_occupants(conversation.counterpart, conversation.account);