fixed pausing while 1k messages are in the channel

This commit is contained in:
fourtf
2018-12-04 08:56:07 +01:00
parent a618b01c03
commit 96328a5e25
3 changed files with 22 additions and 11 deletions
+15 -10
View File
@@ -246,16 +246,19 @@ void ChannelView::updatePauseTimer()
if (this->pauses_.empty())
{
/// No pauses so we can stop the timer
this->pauseEnd = boost::none;
this->pauseEnd_ = boost::none;
this->pauseTimer_.stop();
this->scrollBar_->offset(this->pauseScrollOffset_);
this->pauseScrollOffset_ = 0;
this->queueLayout();
}
else if (std::any_of(this->pauses_.begin(), this->pauses_.end(),
[](auto &&value) { return !value.second; }))
{
/// Some of the pauses are infinite
this->pauseEnd = boost::none;
this->pauseEnd_ = boost::none;
this->pauseTimer_.stop();
}
else
@@ -266,10 +269,10 @@ void ChannelView::updatePauseTimer()
[](auto &&a, auto &&b) { return a.second > b.second; })
->second.get();
if (max != this->pauseEnd)
if (max != this->pauseEnd_)
{
/// Start the timer
this->pauseEnd = max;
this->pauseEnd_ = max;
this->pauseTimer_.start(
duration_cast<milliseconds>(max - SteadyClock::now()));
}
@@ -605,16 +608,18 @@ void ChannelView::messageAppended(MessagePtr &message,
if (this->messages_.pushBack(MessageLayoutPtr(messageRef), deleted))
{
// if (!this->isPaused()) {
if (this->scrollBar_->isAtBottom())
if (this->paused())
{
this->scrollBar_->scrollToBottom();
if (!this->scrollBar_->isAtBottom())
this->pauseScrollOffset_--;
}
else
{
this->scrollBar_->offset(-1);
if (this->scrollBar_->isAtBottom())
this->scrollBar_->scrollToBottom();
else
this->scrollBar_->offset(-1);
}
// }
}
if (!messageFlags->has(MessageFlag::DoNotTriggerNotification))
@@ -692,7 +697,7 @@ void ChannelView::messageRemoveFromStart(MessagePtr &message)
void ChannelView::messageReplaced(size_t index, MessagePtr &replacement)
{
if (index >= this->messages_.getSnapshot().size() || index < 0)
if (index >= this->messages_.getSnapshot().size())
{
return;
}