From 76679de2e09a0a5abae794289bdce15f2871f9e4 Mon Sep 17 00:00:00 2001 From: TriKriSta Date: Wed, 21 Aug 2019 15:30:17 +0300 Subject: [PATCH] feat: check chat status before start a search --- src/widget/form/genericchatform.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 102854b2b..1a99b1253 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -940,7 +940,17 @@ void GenericChatForm::onSearchTriggered() void GenericChatForm::searchInBegin(const QString& phrase, const ParameterSearch& parameter) { - disableSearchText(); + if (phrase.isEmpty()) { + disableSearchText(); + + return; + } + + if (chatLog.getNextIdx().get() == messages.rbegin()->first.get() + 1) { + disableSearchText(); + } else { + goToCurrentDate(); + } if (!parameter.time.isNull()) { LoadHistoryDialog::LoadType type = (parameter.period == PeriodSearch::BeforeDate) @@ -992,7 +1002,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); + 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();