From 146d93e1598ed49bee838990af2fcac2869d5209 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Sat, 4 Apr 2020 22:45:30 -0700 Subject: [PATCH] revert(chatlog): "add comments for functions that load history" This reverts commit 5fc1afbab51d06133e2fc1a05d6ef0e8f175ff86. --- src/widget/form/genericchatform.cpp | 34 +++++++---------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index 5b6fab4bb..927b2735d 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -685,11 +685,6 @@ QDateTime GenericChatForm::getTime(const ChatLine::Ptr &chatLine) const return QDateTime(); } -/** - * @brief GenericChatForm::loadHistory load history - * @param time start date - * @param type indicates the direction of loading history - */ void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog::LoadType type) { chatWidget->clear(); @@ -705,10 +700,6 @@ void GenericChatForm::loadHistory(const QDateTime &time, const LoadHistoryDialog } } -/** - * @brief GenericChatForm::loadHistoryTo load history before to date "time" or before the first "messages" item - * @param time start date - */ void GenericChatForm::loadHistoryTo(const QDateTime &time) { chatWidget->setScroll(false); @@ -735,11 +726,6 @@ void GenericChatForm::loadHistoryTo(const QDateTime &time) } } -/** - * @brief GenericChatForm::loadHistoryFrom load history starting from date "time" or from the last "messages" item - * @param time start date - * @return true if function loaded history else false - */ bool GenericChatForm::loadHistoryFrom(const QDateTime &time) { chatWidget->setScroll(false); @@ -750,17 +736,19 @@ bool GenericChatForm::loadHistoryFrom(const QDateTime &time) begin = firstItemAfterDate(time.date(), chatLog); } - const auto end = chatLog.getNextIdx() < begin + DEF_NUM_MSG_TO_LOAD - ? chatLog.getNextIdx() - : begin + DEF_NUM_MSG_TO_LOAD; + int add = DEF_NUM_MSG_TO_LOAD; + if (begin.get() + DEF_NUM_MSG_TO_LOAD > chatLog.getNextIdx().get()) { + auto t = chatLog.getNextIdx(); + add = chatLog.getNextIdx().get() - begin.get(); + } - // The chatLog.getNextIdx() is usually 1 more than the idx on last "messages" item - // so if we have nothing to load, "add" is equal 1 - if (end - begin <= 1) { + if (add <= 1) { chatWidget->setScroll(true); return false; } + auto end = ChatLogIdx(begin.get() + add); + renderMessages(begin, end); return true; @@ -1219,17 +1207,11 @@ void GenericChatForm::goToCurrentDate() renderMessages(begin, end); } -/** - * @brief GenericChatForm::loadHistoryLower load history after scrolling chatlog before first "messages" item - */ void GenericChatForm::loadHistoryLower() { loadHistoryTo(QDateTime()); } -/** - * @brief GenericChatForm::loadHistoryUpper load history after scrolling chatlog after last "messages" item - */ void GenericChatForm::loadHistoryUpper() { if (messages.empty()) {