Browse Source

revert(chatlog): "fix: data validation during the search"

This reverts commit acb91ed731.
reviewable/pr6374/r3
Anthony Bilinski 5 years ago
parent
commit
3a19eaddb5
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 18
      src/model/chathistory.cpp
  2. 9
      src/widget/form/genericchatform.cpp

18
src/model/chathistory.cpp

@ -160,19 +160,13 @@ SearchResult ChatHistory::searchBackward(SearchPos startIdx, const QString& phra @@ -160,19 +160,13 @@ SearchResult ChatHistory::searchBackward(SearchPos startIdx, const QString& phra
history->getDateWhereFindPhrase(f.getPublicKey(), earliestMessageDate, phrase,
parameter);
if (dateWherePhraseFound.isValid()) {
auto loadIdx = history->getNumMessagesForFriendBeforeDate(f.getPublicKey(), dateWherePhraseFound);
loadHistoryIntoSessionChatLog(ChatLogIdx(loadIdx));
// Reset search pos to the message we just loaded to avoid a double search
startIdx.logIdx = ChatLogIdx(loadIdx);
startIdx.numMatches = 0;
return sessionChatLog.searchBackward(startIdx, phrase, parameter);
}
auto loadIdx = history->getNumMessagesForFriendBeforeDate(f.getPublicKey(), dateWherePhraseFound);
loadHistoryIntoSessionChatLog(ChatLogIdx(loadIdx));
SearchResult ret;
ret.found = false;
return ret;
// Reset search pos to the message we just loaded to avoid a double search
startIdx.logIdx = ChatLogIdx(loadIdx);
startIdx.numMatches = 0;
return sessionChatLog.searchBackward(startIdx, phrase, parameter);
}
ChatLogIdx ChatHistory::getFirstIdx() const

9
src/widget/form/genericchatform.cpp

@ -1004,13 +1004,7 @@ void GenericChatForm::onSearchUp(const QString& phrase, const ParameterSearch& p @@ -1004,13 +1004,7 @@ void GenericChatForm::onSearchUp(const QString& phrase, const ParameterSearch& p
void GenericChatForm::onSearchDown(const QString& phrase, const ParameterSearch& parameter)
{
auto result = chatLog.searchForward(searchPos, phrase, parameter);
if (result.found && result.pos.logIdx.get() > messages.end()->first.get()) {
const auto dt = chatLog.at(result.pos.logIdx).getTimestamp();
loadHistory(dt, LoadHistoryDialog::from);
}
auto result = chatLog.searchForward(searchPos, phrase, parameter);
handleSearchResult(result, SearchDirection::Down);
}
@ -1032,7 +1026,6 @@ void GenericChatForm::handleSearchResult(SearchResult result, SearchDirection di @@ -1032,7 +1026,6 @@ void GenericChatForm::handleSearchResult(SearchResult result, SearchDirection di
chatWidget->scrollToLine(msg);
auto text = qobject_cast<Text*>(msg->getContent(1));
text->visibilityChanged(true);
text->selectText(result.exp, std::make_pair(result.start, result.len));
});
}

Loading…
Cancel
Save