From 2a66a6a83417615da8fc7437e5181c4c194b7b07 Mon Sep 17 00:00:00 2001 From: Maitreyee Joshi Date: Mon, 29 May 2017 20:53:56 -0700 Subject: [PATCH] added search through all convos --- .../chat/client/simplegui/SearchPanel.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/codeu/chat/client/simplegui/SearchPanel.java b/src/codeu/chat/client/simplegui/SearchPanel.java index 70063e06b..92326861b 100644 --- a/src/codeu/chat/client/simplegui/SearchPanel.java +++ b/src/codeu/chat/client/simplegui/SearchPanel.java @@ -176,16 +176,25 @@ private void searchAndDisplay(ConversationSummary conversation, String searchTer // Here we need to call a search function that returns a ListViewable object of the messages to display. // This then replaces the conversation contents call in the for loop. - for (final Message m : clientContext.message.getConversationContents(conversation)) { - // Stubby inclusion check for search. - if (m.content.toLowerCase().contains(searchTerm.toLowerCase())) { - // Display author name if available. Otherwise display the author UUID. - final String authorName = clientContext.user.getName(m.author); + for (final ConversationSummary cs : clientContext.conversation.getConversationSummaries()) { + int first = 1; + for (final Message m : clientContext.message.getConversationContents(cs)) { + // Stubby inclusion check for search. + if (m.content.toLowerCase().contains(searchTerm.toLowerCase())) { + // Display author name if available. Otherwise display the author UUID. + if (first == 1) { + String convoTitle = cs.title; + messageListModel.addElement(convoTitle); + first = 0; + } + + final String authorName = clientContext.user.getName(m.author); - final String displayString = String.format("%s: [%s]: %s", - ((authorName == null) ? m.author : authorName), m.creation, m.content); + final String displayString = String.format("%s: [%s]: %s", + ((authorName == null) ? m.author : authorName), m.creation, m.content); - messageListModel.addElement(displayString); + messageListModel.addElement(displayString); + } } } }