mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Respect window active state on mark as read.
This commit is contained in:
parent
ff352d7647
commit
9d4840c0de
23 changed files with 156 additions and 107 deletions
|
@ -57,11 +57,7 @@ void SendBotCallbackData(
|
||||||
const auto bot = item->getMessageBot();
|
const auto bot = item->getMessageBot();
|
||||||
const auto fullId = item->fullId();
|
const auto fullId = item->fullId();
|
||||||
const auto getButton = [=] {
|
const auto getButton = [=] {
|
||||||
return HistoryMessageMarkupButton::Get(
|
return HistoryMessageMarkupButton::Get(owner, fullId, row, column);
|
||||||
owner,
|
|
||||||
fullId,
|
|
||||||
row,
|
|
||||||
column);
|
|
||||||
};
|
};
|
||||||
const auto button = getButton();
|
const auto button = getButton();
|
||||||
if (!button || button->requestId) {
|
if (!button || button->requestId) {
|
||||||
|
|
|
@ -194,7 +194,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
|
||||||
showToast(tr::lng_share_done(tr::now));
|
showToast(tr::lng_share_done(tr::now));
|
||||||
};
|
};
|
||||||
auto filterCallback = [](not_null<Data::Thread*> thread) {
|
auto filterCallback = [](not_null<Data::Thread*> thread) {
|
||||||
return thread->canWrite(); // #TODO forum share
|
return thread->canWrite();
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto scheduleStyle = [&] {
|
const auto scheduleStyle = [&] {
|
||||||
|
|
|
@ -255,9 +255,6 @@ void Forum::requestSomeStale() {
|
||||||
const auto rootId = *i;
|
const auto rootId = *i;
|
||||||
i = _staleRootIds.erase(i);
|
i = _staleRootIds.erase(i);
|
||||||
|
|
||||||
if (_topicRequests.contains(rootId)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
rootIds.push_back(MTP_int(rootId));
|
rootIds.push_back(MTP_int(rootId));
|
||||||
if (rootIds.size() == kStalePerRequest) {
|
if (rootIds.size() == kStalePerRequest) {
|
||||||
break;
|
break;
|
||||||
|
@ -279,10 +276,12 @@ void Forum::requestSomeStale() {
|
||||||
channel()->inputChannel,
|
channel()->inputChannel,
|
||||||
MTP_vector<MTPint>(rootIds))
|
MTP_vector<MTPint>(rootIds))
|
||||||
).done([=](const MTPmessages_ForumTopics &result) {
|
).done([=](const MTPmessages_ForumTopics &result) {
|
||||||
|
_staleRequestId = 0;
|
||||||
applyReceivedTopics(result);
|
applyReceivedTopics(result);
|
||||||
call();
|
call();
|
||||||
finish();
|
finish();
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
|
_staleRequestId = 0;
|
||||||
call();
|
call();
|
||||||
finish();
|
finish();
|
||||||
}).send();
|
}).send();
|
||||||
|
@ -301,35 +300,19 @@ void Forum::finishTopicRequest(MsgId rootId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Forum::requestTopic(MsgId rootId, Fn<void()> done) {
|
void Forum::requestTopic(MsgId rootId, Fn<void()> done) {
|
||||||
_staleRootIds.remove(rootId);
|
|
||||||
|
|
||||||
auto &request = _topicRequests[rootId];
|
auto &request = _topicRequests[rootId];
|
||||||
if (done) {
|
if (done) {
|
||||||
request.callbacks.push_back(std::move(done));
|
request.callbacks.push_back(std::move(done));
|
||||||
}
|
}
|
||||||
if (request.id) {
|
if (!request.id
|
||||||
return;
|
&& _staleRootIds.emplace(rootId).second
|
||||||
|
&& (_staleRootIds.size() == 1)) {
|
||||||
|
crl::on_main(&session(), [peer = channel()] {
|
||||||
|
if (const auto forum = peer->forum()) {
|
||||||
|
forum->requestSomeStale();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const auto call = [=] {
|
|
||||||
finishTopicRequest(rootId);
|
|
||||||
};
|
|
||||||
const auto type = Histories::RequestType::History;
|
|
||||||
auto &histories = owner().histories();
|
|
||||||
request.id = histories.sendRequest(_history, type, [=](
|
|
||||||
Fn<void()> finish) {
|
|
||||||
return session().api().request(
|
|
||||||
MTPchannels_GetForumTopicsByID(
|
|
||||||
channel()->inputChannel,
|
|
||||||
MTP_vector<MTPint>(1, MTP_int(rootId.bare)))
|
|
||||||
).done([=](const MTPmessages_ForumTopics &result) {
|
|
||||||
applyReceivedTopics(result);
|
|
||||||
call();
|
|
||||||
finish();
|
|
||||||
}).fail([=] {
|
|
||||||
call();
|
|
||||||
finish();
|
|
||||||
}).send();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ForumTopic *Forum::applyTopicAdded(
|
ForumTopic *Forum::applyTopicAdded(
|
||||||
|
|
|
@ -86,7 +86,7 @@ RepliesList::RepliesList(not_null<History*> history, MsgId rootId)
|
||||||
| MessageUpdate::Flag::Destroyed
|
| MessageUpdate::Flag::Destroyed
|
||||||
) | rpl::filter([=](const MessageUpdate &update) {
|
) | rpl::filter([=](const MessageUpdate &update) {
|
||||||
return applyUpdate(update);
|
return applyUpdate(update);
|
||||||
}) | rpl::to_empty | rpl::start_to_stream(_listChanges, _lifetime);
|
}) | rpl::to_empty | rpl::start_to_stream(_instantChanges, _lifetime);
|
||||||
|
|
||||||
_history->owner().channelDifferenceTooLong(
|
_history->owner().channelDifferenceTooLong(
|
||||||
) | rpl::filter([=](not_null<ChannelData*> channel) {
|
) | rpl::filter([=](not_null<ChannelData*> channel) {
|
||||||
|
@ -114,12 +114,18 @@ rpl::producer<MessagesSlice> RepliesList::source(
|
||||||
auto lifetime = rpl::lifetime();
|
auto lifetime = rpl::lifetime();
|
||||||
const auto viewer = lifetime.make_state<Viewer>();
|
const auto viewer = lifetime.make_state<Viewer>();
|
||||||
const auto push = [=] {
|
const auto push = [=] {
|
||||||
viewer->scheduled = false;
|
if (viewer->scheduled) {
|
||||||
if (buildFromData(viewer)) {
|
viewer->scheduled = false;
|
||||||
appendClientSideMessages(viewer->slice);
|
if (buildFromData(viewer)) {
|
||||||
consumer.put_next_copy(viewer->slice);
|
appendClientSideMessages(viewer->slice);
|
||||||
|
consumer.put_next_copy(viewer->slice);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const auto pushInstant = [=] {
|
||||||
|
viewer->scheduled = true;
|
||||||
|
push();
|
||||||
|
};
|
||||||
const auto pushDelayed = [=] {
|
const auto pushDelayed = [=] {
|
||||||
if (!viewer->scheduled) {
|
if (!viewer->scheduled) {
|
||||||
viewer->scheduled = true;
|
viewer->scheduled = true;
|
||||||
|
@ -144,7 +150,10 @@ rpl::producer<MessagesSlice> RepliesList::source(
|
||||||
_listChanges.events(
|
_listChanges.events(
|
||||||
) | rpl::start_with_next(pushDelayed, lifetime);
|
) | rpl::start_with_next(pushDelayed, lifetime);
|
||||||
|
|
||||||
push();
|
_instantChanges.events(
|
||||||
|
) | rpl::start_with_next(pushInstant, lifetime);
|
||||||
|
|
||||||
|
pushInstant();
|
||||||
return lifetime;
|
return lifetime;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ private:
|
||||||
std::optional<int> _skippedAfter;
|
std::optional<int> _skippedAfter;
|
||||||
rpl::variable<std::optional<int>> _fullCount;
|
rpl::variable<std::optional<int>> _fullCount;
|
||||||
rpl::event_stream<> _listChanges;
|
rpl::event_stream<> _listChanges;
|
||||||
|
rpl::event_stream<> _instantChanges;
|
||||||
std::optional<MsgId> _loadingAround;
|
std::optional<MsgId> _loadingAround;
|
||||||
rpl::variable<std::optional<int>> _unreadCount;
|
rpl::variable<std::optional<int>> _unreadCount;
|
||||||
MsgId _inboxReadTillId = 0;
|
MsgId _inboxReadTillId = 0;
|
||||||
|
|
|
@ -975,10 +975,10 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
|
||||||
auto readTill = (HistoryItem*)nullptr;
|
auto readTill = (HistoryItem*)nullptr;
|
||||||
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
if (readTill && _widget->doWeReadServerHistory()) {
|
if (readTill && _widget->markingMessagesRead()) {
|
||||||
session().data().histories().readInboxTill(readTill);
|
session().data().histories().readInboxTill(readTill);
|
||||||
}
|
}
|
||||||
if (!readContents.empty() && _widget->doWeReadMentions()) {
|
if (!readContents.empty() && _widget->markingContentsRead()) {
|
||||||
session().api().markContentsRead(readContents);
|
session().api().markContentsRead(readContents);
|
||||||
}
|
}
|
||||||
_userpicsCache.clear();
|
_userpicsCache.clear();
|
||||||
|
@ -2796,8 +2796,8 @@ void HistoryInner::keyPressEvent(QKeyEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryInner::checkHistoryActivation() {
|
void HistoryInner::checkActivation() {
|
||||||
if (!_widget->doWeReadServerHistory()) {
|
if (!_widget->markingMessagesRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
adjustCurrent(_visibleAreaBottom);
|
adjustCurrent(_visibleAreaBottom);
|
||||||
|
@ -3020,7 +3020,7 @@ void HistoryInner::visibleAreaUpdated(int top, int bottom) {
|
||||||
from,
|
from,
|
||||||
till);
|
till);
|
||||||
}
|
}
|
||||||
checkHistoryActivation();
|
checkActivation();
|
||||||
|
|
||||||
_emojiInteractions->visibleAreaUpdated(
|
_emojiInteractions->visibleAreaUpdated(
|
||||||
_visibleAreaTop,
|
_visibleAreaTop,
|
||||||
|
|
|
@ -108,7 +108,7 @@ public:
|
||||||
|
|
||||||
void setItemsRevealHeight(int revealHeight);
|
void setItemsRevealHeight(int revealHeight);
|
||||||
void changeItemsRevealHeight(int revealHeight);
|
void changeItemsRevealHeight(int revealHeight);
|
||||||
void checkHistoryActivation();
|
void checkActivation();
|
||||||
void recountHistoryGeometry();
|
void recountHistoryGeometry();
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
|
|
|
@ -2879,10 +2879,10 @@ void HistoryWidget::newItemAdded(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here in non-resized state we can't rely on results of
|
// If we get here in non-resized state we can't rely on results of
|
||||||
// doWeReadServerHistory() and mark chat as read.
|
// markingMessagesRead() and mark chat as read.
|
||||||
// If we receive N messages being not at bottom:
|
// If we receive N messages being not at bottom:
|
||||||
// - on first message we set unreadcount += 1, firstUnreadMessage.
|
// - on first message we set unreadcount += 1, firstUnreadMessage.
|
||||||
// - on second we get wrong doWeReadServerHistory() and read both.
|
// - on second we get wrong markingMessagesRead() and read both.
|
||||||
session().data().sendHistoryChangeNotifications();
|
session().data().sendHistoryChangeNotifications();
|
||||||
|
|
||||||
if (item->isSending()) {
|
if (item->isSending()) {
|
||||||
|
@ -2892,7 +2892,7 @@ void HistoryWidget::newItemAdded(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
if (item->showNotification()) {
|
if (item->showNotification()) {
|
||||||
destroyUnreadBar();
|
destroyUnreadBar();
|
||||||
if (doWeReadServerHistory()) {
|
if (markingMessagesRead()) {
|
||||||
if (item->isUnreadMention() && !item->isUnreadMedia()) {
|
if (item->isUnreadMention() && !item->isUnreadMedia()) {
|
||||||
session().api().markContentsRead(item);
|
session().api().markContentsRead(item);
|
||||||
}
|
}
|
||||||
|
@ -2916,7 +2916,7 @@ void HistoryWidget::maybeMarkReactionsRead(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
const auto view = item->mainView();
|
const auto view = item->mainView();
|
||||||
const auto itemTop = _list->itemTop(view);
|
const auto itemTop = _list->itemTop(view);
|
||||||
if (itemTop <= 0 || !doWeReadMentions()) {
|
if (itemTop <= 0 || !markingContentsRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto reactionCenter
|
const auto reactionCenter
|
||||||
|
@ -3050,7 +3050,7 @@ void HistoryWidget::messagesReceived(PeerData *peer, const MTPmessages_Messages
|
||||||
_preloadDownRequest = 0;
|
_preloadDownRequest = 0;
|
||||||
preloadHistoryIfNeeded();
|
preloadHistoryIfNeeded();
|
||||||
if (_history->loadedAtBottom()) {
|
if (_history->loadedAtBottom()) {
|
||||||
checkHistoryActivation();
|
checkActivation();
|
||||||
}
|
}
|
||||||
} else if (_firstLoadRequest == requestId) {
|
} else if (_firstLoadRequest == requestId) {
|
||||||
if (toMigrated) {
|
if (toMigrated) {
|
||||||
|
@ -3114,23 +3114,23 @@ void HistoryWidget::windowShown() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::doWeReadServerHistory() const {
|
bool HistoryWidget::markingMessagesRead() const {
|
||||||
return doWeReadMentions() && !session().supportMode();
|
return markingContentsRead() && !session().supportMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::doWeReadMentions() const {
|
bool HistoryWidget::markingContentsRead() const {
|
||||||
return _history
|
return _history
|
||||||
&& _list
|
&& _list
|
||||||
&& _historyInited
|
&& _historyInited
|
||||||
&& !_firstLoadRequest
|
&& !_firstLoadRequest
|
||||||
&& !_delayedShowAtRequest
|
&& !_delayedShowAtRequest
|
||||||
&& !_a_show.animating()
|
&& !_a_show.animating()
|
||||||
&& controller()->widget()->doWeMarkAsRead();
|
&& controller()->widget()->markingAsRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::checkHistoryActivation() {
|
void HistoryWidget::checkActivation() {
|
||||||
if (_list) {
|
if (_list) {
|
||||||
_list->checkHistoryActivation();
|
_list->checkActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3980,7 +3980,7 @@ void HistoryWidget::doneShow() {
|
||||||
if (_requestsBar) {
|
if (_requestsBar) {
|
||||||
_requestsBar->finishAnimating();
|
_requestsBar->finishAnimating();
|
||||||
}
|
}
|
||||||
checkHistoryActivation();
|
checkActivation();
|
||||||
controller()->widget()->setInnerFocus();
|
controller()->widget()->setInnerFocus();
|
||||||
_preserveScrollTop = false;
|
_preserveScrollTop = false;
|
||||||
checkSuggestToGigagroup();
|
checkSuggestToGigagroup();
|
||||||
|
|
|
@ -129,10 +129,10 @@ public:
|
||||||
void setGeometryWithTopMoved(const QRect &newGeometry, int topDelta);
|
void setGeometryWithTopMoved(const QRect &newGeometry, int topDelta);
|
||||||
|
|
||||||
void windowShown();
|
void windowShown();
|
||||||
[[nodiscard]] bool doWeReadServerHistory() const;
|
[[nodiscard]] bool markingMessagesRead() const;
|
||||||
[[nodiscard]] bool doWeReadMentions() const;
|
[[nodiscard]] bool markingContentsRead() const;
|
||||||
bool skipItemRepaint();
|
bool skipItemRepaint();
|
||||||
void checkHistoryActivation();
|
void checkActivation();
|
||||||
|
|
||||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
||||||
|
|
||||||
|
|
|
@ -429,11 +429,13 @@ not_null<ListDelegate*> ListWidget::delegate() const {
|
||||||
|
|
||||||
void ListWidget::refreshViewer() {
|
void ListWidget::refreshViewer() {
|
||||||
_viewerLifetime.destroy();
|
_viewerLifetime.destroy();
|
||||||
|
_refreshingViewer = true;
|
||||||
_delegate->listSource(
|
_delegate->listSource(
|
||||||
_aroundPosition,
|
_aroundPosition,
|
||||||
_idsLimit,
|
_idsLimit,
|
||||||
_idsLimit
|
_idsLimit
|
||||||
) | rpl::start_with_next([=](Data::MessagesSlice &&slice) {
|
) | rpl::start_with_next([=](Data::MessagesSlice &&slice) {
|
||||||
|
_refreshingViewer = false;
|
||||||
std::swap(_slice, slice);
|
std::swap(_slice, slice);
|
||||||
refreshRows(slice);
|
refreshRows(slice);
|
||||||
}, _viewerLifetime);
|
}, _viewerLifetime);
|
||||||
|
@ -453,6 +455,7 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
|
||||||
) - 1;
|
) - 1;
|
||||||
|
|
||||||
auto destroyingBarElement = _bar.element;
|
auto destroyingBarElement = _bar.element;
|
||||||
|
_resizePending = true;
|
||||||
_items.clear();
|
_items.clear();
|
||||||
_items.reserve(_slice.ids.size());
|
_items.reserve(_slice.ids.size());
|
||||||
auto nearestIndex = -1;
|
auto nearestIndex = -1;
|
||||||
|
@ -486,7 +489,7 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
|
||||||
if (_emptyInfo) {
|
if (_emptyInfo) {
|
||||||
_emptyInfo->setVisible(isEmpty());
|
_emptyInfo->setVisible(isEmpty());
|
||||||
}
|
}
|
||||||
_delegate->listContentRefreshed();
|
checkActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<int> ListWidget::scrollTopForPosition(
|
std::optional<int> ListWidget::scrollTopForPosition(
|
||||||
|
@ -1728,6 +1731,7 @@ void ListWidget::updateItemsGeometry() {
|
||||||
void ListWidget::updateSize() {
|
void ListWidget::updateSize() {
|
||||||
resizeToWidth(width(), _minHeight);
|
resizeToWidth(width(), _minHeight);
|
||||||
updateVisibleTopItem();
|
updateVisibleTopItem();
|
||||||
|
_resizePending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListWidget::resizeToWidth(int newWidth, int minHeight) {
|
void ListWidget::resizeToWidth(int newWidth, int minHeight) {
|
||||||
|
@ -1936,6 +1940,43 @@ Ui::ChatPaintContext ListWidget::preparePaintContext(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ListWidget::markingContentsRead() const {
|
||||||
|
return _showFinished
|
||||||
|
&& !_refreshingViewer
|
||||||
|
&& controller()->widget()->markingAsRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ListWidget::markingMessagesRead() const {
|
||||||
|
return markingContentsRead() && !session().supportMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListWidget::showFinished() {
|
||||||
|
_showFinished = true;
|
||||||
|
checkActivation();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ListWidget::checkActivation() {
|
||||||
|
if (_resizePending
|
||||||
|
|| _visibleTop >= _visibleBottom
|
||||||
|
|| !markingMessagesRead()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto h = height();
|
||||||
|
const auto t = _visibleTop;
|
||||||
|
const auto b = _visibleBottom;
|
||||||
|
const auto r = _itemsRevealHeight;
|
||||||
|
auto a = 0;
|
||||||
|
for (const auto &view : _itemRevealPending) {
|
||||||
|
a += view->height();
|
||||||
|
}
|
||||||
|
for (const auto &view : ranges::views::reverse(_items)) {
|
||||||
|
const auto bottom = itemTop(view) + view->height();
|
||||||
|
if (_visibleBottom + _itemsRevealHeight >= bottom) {
|
||||||
|
delegate()->listMarkReadTill(view->data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ListWidget::paintEvent(QPaintEvent *e) {
|
void ListWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (Ui::skipPaintEvent(this, e)) {
|
if (Ui::skipPaintEvent(this, e)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1944,10 +1985,10 @@ void ListWidget::paintEvent(QPaintEvent *e) {
|
||||||
auto readTill = (HistoryItem*)nullptr;
|
auto readTill = (HistoryItem*)nullptr;
|
||||||
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
auto readContents = base::flat_set<not_null<HistoryItem*>>();
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
if (readTill) {
|
if (readTill && markingMessagesRead()) {
|
||||||
_delegate->listMarkReadTill(readTill);
|
_delegate->listMarkReadTill(readTill);
|
||||||
}
|
}
|
||||||
if (!readContents.empty()) {
|
if (!readContents.empty() && markingContentsRead()) {
|
||||||
_delegate->listMarkContentsRead(readContents);
|
_delegate->listMarkContentsRead(readContents);
|
||||||
}
|
}
|
||||||
_userpicsCache.clear();
|
_userpicsCache.clear();
|
||||||
|
@ -2137,7 +2178,7 @@ void ListWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
void ListWidget::maybeMarkReactionsRead(not_null<HistoryItem*> item) {
|
void ListWidget::maybeMarkReactionsRead(not_null<HistoryItem*> item) {
|
||||||
const auto view = viewForItem(item);
|
const auto view = viewForItem(item);
|
||||||
if (!view) {
|
if (!view || !markingContentsRead()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto top = itemTop(view);
|
const auto top = itemTop(view);
|
||||||
|
@ -3592,8 +3633,10 @@ void ListWidget::refreshAttachmentsAtIndex(int index) {
|
||||||
void ListWidget::refreshAttachmentsFromTill(int from, int till) {
|
void ListWidget::refreshAttachmentsFromTill(int from, int till) {
|
||||||
Expects(from >= 0 && from <= till && till <= int(_items.size()));
|
Expects(from >= 0 && from <= till && till <= int(_items.size()));
|
||||||
|
|
||||||
if (from == till) {
|
const auto guard = gsl::finally([&] {
|
||||||
updateSize();
|
updateSize();
|
||||||
|
});
|
||||||
|
if (from == till) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto view = _items[from].get();
|
auto view = _items[from].get();
|
||||||
|
|
|
@ -245,6 +245,11 @@ public:
|
||||||
[[nodiscard]] bool loadedAtBottom() const;
|
[[nodiscard]] bool loadedAtBottom() const;
|
||||||
[[nodiscard]] bool isEmpty() const;
|
[[nodiscard]] bool isEmpty() const;
|
||||||
|
|
||||||
|
[[nodiscard]] bool markingContentsRead() const;
|
||||||
|
[[nodiscard]] bool markingMessagesRead() const;
|
||||||
|
void showFinished();
|
||||||
|
void checkActivation();
|
||||||
|
|
||||||
[[nodiscard]] bool hasCopyRestriction(HistoryItem *item = nullptr) const;
|
[[nodiscard]] bool hasCopyRestriction(HistoryItem *item = nullptr) const;
|
||||||
[[nodiscard]] bool hasCopyMediaRestriction(
|
[[nodiscard]] bool hasCopyMediaRestriction(
|
||||||
not_null<HistoryItem*> item) const;
|
not_null<HistoryItem*> item) const;
|
||||||
|
@ -692,6 +697,9 @@ private:
|
||||||
Qt::CursorShape _cursor = style::cur_default;
|
Qt::CursorShape _cursor = style::cur_default;
|
||||||
|
|
||||||
bool _isChatWide = false;
|
bool _isChatWide = false;
|
||||||
|
bool _refreshingViewer = false;
|
||||||
|
bool _showFinished = false;
|
||||||
|
bool _resizePending = false;
|
||||||
|
|
||||||
// _menu must be destroyed before _whoReactedMenuLifetime.
|
// _menu must be destroyed before _whoReactedMenuLifetime.
|
||||||
rpl::lifetime _whoReactedMenuLifetime;
|
rpl::lifetime _whoReactedMenuLifetime;
|
||||||
|
|
|
@ -261,6 +261,10 @@ QPixmap PinnedWidget::grabForShowAnimation(const Window::SectionSlideParams &par
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PinnedWidget::checkActivation() {
|
||||||
|
_inner->checkActivation();
|
||||||
|
}
|
||||||
|
|
||||||
void PinnedWidget::doSetInnerFocus() {
|
void PinnedWidget::doSetInnerFocus() {
|
||||||
_inner->setFocus();
|
_inner->setFocus();
|
||||||
}
|
}
|
||||||
|
@ -421,6 +425,7 @@ void PinnedWidget::showAnimatedHook(
|
||||||
|
|
||||||
void PinnedWidget::showFinishedHook() {
|
void PinnedWidget::showFinishedHook() {
|
||||||
_topBar->setAnimatingMode(false);
|
_topBar->setAnimatingMode(false);
|
||||||
|
_inner->showFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PinnedWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
bool PinnedWidget::floatPlayerHandleWheelEvent(QEvent *e) {
|
||||||
|
|
|
@ -138,7 +138,7 @@ public:
|
||||||
bool cornerButtonsUnreadMayBeShown() override;
|
bool cornerButtonsUnreadMayBeShown() override;
|
||||||
bool cornerButtonsHas(CornerButtonType type) override;
|
bool cornerButtonsHas(CornerButtonType type) override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
@ -146,8 +146,8 @@ protected:
|
||||||
const Window::SectionSlideParams ¶ms) override;
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
void checkActivation() override;
|
||||||
|
|
||||||
private:
|
|
||||||
void onScroll();
|
void onScroll();
|
||||||
void updateInnerVisibleArea();
|
void updateInnerVisibleArea();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
|
|
@ -1872,6 +1872,10 @@ QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams &pa
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RepliesWidget::checkActivation() {
|
||||||
|
_inner->checkActivation();
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::doSetInnerFocus() {
|
void RepliesWidget::doSetInnerFocus() {
|
||||||
if (!_inner->getSelectedText().rich.text.isEmpty()
|
if (!_inner->getSelectedText().rich.text.isEmpty()
|
||||||
|| !_inner->getSelectedItems().empty()
|
|| !_inner->getSelectedItems().empty()
|
||||||
|
@ -2236,6 +2240,7 @@ void RepliesWidget::showFinishedHook() {
|
||||||
} else {
|
} else {
|
||||||
_composeControls->showFinished();
|
_composeControls->showFinished();
|
||||||
}
|
}
|
||||||
|
_inner->showFinished();
|
||||||
if (_rootView) {
|
if (_rootView) {
|
||||||
_rootView->show();
|
_rootView->show();
|
||||||
}
|
}
|
||||||
|
@ -2338,16 +2343,12 @@ void RepliesWidget::listSelectionChanged(SelectedItems &&items) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::listMarkReadTill(not_null<HistoryItem*> item) {
|
void RepliesWidget::listMarkReadTill(not_null<HistoryItem*> item) {
|
||||||
if (true/*doWeReadServerHistory()*/) { // #TODO forum active
|
_replies->readTill(item);
|
||||||
_replies->readTill(item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::listMarkContentsRead(
|
void RepliesWidget::listMarkContentsRead(
|
||||||
const base::flat_set<not_null<HistoryItem*>> &items) {
|
const base::flat_set<not_null<HistoryItem*>> &items) {
|
||||||
if (true/*doWeReadMentions()*/) { // #TODO forum active
|
session().api().markContentsRead(items);
|
||||||
session().api().markContentsRead(items);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagesBarData RepliesWidget::listMessagesBar(
|
MessagesBarData RepliesWidget::listMessagesBar(
|
||||||
|
|
|
@ -182,16 +182,16 @@ public:
|
||||||
bool cornerButtonsUnreadMayBeShown() override;
|
bool cornerButtonsUnreadMayBeShown() override;
|
||||||
bool cornerButtonsHas(CornerButtonType type) override;
|
bool cornerButtonsHas(CornerButtonType type) override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
void showAnimatedHook(
|
void showAnimatedHook(
|
||||||
const Window::SectionSlideParams ¶ms) override;
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
|
void checkActivation() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
|
||||||
private:
|
|
||||||
void onScroll();
|
void onScroll();
|
||||||
void updateInnerVisibleArea();
|
void updateInnerVisibleArea();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
|
|
@ -895,6 +895,10 @@ QPixmap ScheduledWidget::grabForShowAnimation(const Window::SectionSlideParams &
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScheduledWidget::checkActivation() {
|
||||||
|
_inner->checkActivation();
|
||||||
|
}
|
||||||
|
|
||||||
void ScheduledWidget::doSetInnerFocus() {
|
void ScheduledWidget::doSetInnerFocus() {
|
||||||
_composeControls->focus();
|
_composeControls->focus();
|
||||||
}
|
}
|
||||||
|
@ -1031,6 +1035,7 @@ void ScheduledWidget::showAnimatedHook(
|
||||||
void ScheduledWidget::showFinishedHook() {
|
void ScheduledWidget::showFinishedHook() {
|
||||||
_topBar->setAnimatingMode(false);
|
_topBar->setAnimatingMode(false);
|
||||||
_composeControls->showFinished();
|
_composeControls->showFinished();
|
||||||
|
_inner->showFinished();
|
||||||
|
|
||||||
// We should setup the drag area only after
|
// We should setup the drag area only after
|
||||||
// the section animation is finished,
|
// the section animation is finished,
|
||||||
|
|
|
@ -162,7 +162,7 @@ public:
|
||||||
bool cornerButtonsUnreadMayBeShown() override;
|
bool cornerButtonsUnreadMayBeShown() override;
|
||||||
bool cornerButtonsHas(CornerButtonType type) override;
|
bool cornerButtonsHas(CornerButtonType type) override;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ protected:
|
||||||
const Window::SectionSlideParams ¶ms) override;
|
const Window::SectionSlideParams ¶ms) override;
|
||||||
void showFinishedHook() override;
|
void showFinishedHook() override;
|
||||||
void doSetInnerFocus() override;
|
void doSetInnerFocus() override;
|
||||||
|
void checkActivation() override;
|
||||||
|
|
||||||
private:
|
|
||||||
void onScroll();
|
void onScroll();
|
||||||
void updateInnerVisibleArea();
|
void updateInnerVisibleArea();
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
|
|
|
@ -2060,8 +2060,11 @@ void MainWidget::dialogsToUp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::checkHistoryActivation() {
|
void MainWidget::checkActivation() {
|
||||||
_history->checkHistoryActivation();
|
_history->checkActivation();
|
||||||
|
if (_mainSection) {
|
||||||
|
_mainSection->checkActivation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
|
void MainWidget::showAnimated(const QPixmap &bgAnimCache, bool back) {
|
||||||
|
@ -2223,7 +2226,7 @@ void MainWidget::showAll() {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
floatPlayerCheckVisibility();
|
floatPlayerCheckVisibility();
|
||||||
|
|
||||||
_controller->widget()->checkHistoryActivation();
|
_controller->widget()->checkActivation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::resizeEvent(QResizeEvent *e) {
|
void MainWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -2778,14 +2781,8 @@ void MainWidget::activate() {
|
||||||
_controller->widget()->fixOrder();
|
_controller->widget()->fixOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::isActive() const {
|
bool MainWidget::animatingShow() const {
|
||||||
return isVisible()
|
return _a_show.animating();
|
||||||
&& !_a_show.animating()
|
|
||||||
&& !session().updates().isIdle();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWidget::doWeMarkAsRead() const {
|
|
||||||
return isActive() && !_mainSection;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::isOneColumn() const {
|
bool MainWidget::isOneColumn() const {
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
void windowShown();
|
void windowShown();
|
||||||
|
|
||||||
void dialogsToUp();
|
void dialogsToUp();
|
||||||
void checkHistoryActivation();
|
void checkActivation();
|
||||||
|
|
||||||
[[nodiscard]] PeerData *peer() const;
|
[[nodiscard]] PeerData *peer() const;
|
||||||
[[nodiscard]] Ui::ChatTheme *customChatTheme() const;
|
[[nodiscard]] Ui::ChatTheme *customChatTheme() const;
|
||||||
|
@ -167,8 +167,7 @@ public:
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
Api::SendOptions options);
|
Api::SendOptions options);
|
||||||
|
|
||||||
bool isActive() const;
|
[[nodiscard]] bool animatingShow() const;
|
||||||
[[nodiscard]] bool doWeMarkAsRead() const;
|
|
||||||
|
|
||||||
void showForwardLayer(Data::ForwardDraft &&draft);
|
void showForwardLayer(Data::ForwardDraft &&draft);
|
||||||
void showSendPathsLayer();
|
void showSendPathsLayer();
|
||||||
|
|
|
@ -114,7 +114,7 @@ void MainWindow::initHook() {
|
||||||
windowHandle(),
|
windowHandle(),
|
||||||
&QWindow::activeChanged,
|
&QWindow::activeChanged,
|
||||||
this,
|
this,
|
||||||
[=] { checkHistoryActivation(); },
|
[=] { checkActivation(); },
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
if (Media::SystemMediaControlsManager::Supported()) {
|
if (Media::SystemMediaControlsManager::Supported()) {
|
||||||
|
@ -395,7 +395,7 @@ void MainWindow::destroyLayer() {
|
||||||
setInnerFocus();
|
setInnerFocus();
|
||||||
}
|
}
|
||||||
InvokeQueued(this, [=] {
|
InvokeQueued(this, [=] {
|
||||||
checkHistoryActivation();
|
checkActivation();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ void MainWindow::showLayer(
|
||||||
showBoxOrLayer(std::move(layer), options, animated);
|
showBoxOrLayer(std::move(layer), options, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::ui_isLayerShown() {
|
bool MainWindow::ui_isLayerShown() const {
|
||||||
return _layer != nullptr;
|
return _layer != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,17 +539,19 @@ void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::doWeMarkAsRead() {
|
bool MainWindow::markingAsRead() const {
|
||||||
if (!_main || Ui::isLayerShown()) {
|
return _main
|
||||||
return false;
|
&& !_main->isHidden()
|
||||||
}
|
&& !_main->animatingShow()
|
||||||
return isActive() && _main->doWeMarkAsRead();
|
&& !_layer
|
||||||
|
&& isActive()
|
||||||
|
&& !_main->session().updates().isIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::checkHistoryActivation() {
|
void MainWindow::checkActivation() {
|
||||||
updateIsActive();
|
updateIsActive();
|
||||||
if (_main) {
|
if (_main) {
|
||||||
_main->checkHistoryActivation();
|
_main->checkActivation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,11 @@ public:
|
||||||
|
|
||||||
MainWidget *sessionContent() const;
|
MainWidget *sessionContent() const;
|
||||||
|
|
||||||
[[nodiscard]] bool doWeMarkAsRead();
|
void checkActivation();
|
||||||
|
[[nodiscard]] bool markingAsRead() const;
|
||||||
|
|
||||||
bool takeThirdSectionFromLayer();
|
bool takeThirdSectionFromLayer();
|
||||||
|
|
||||||
void checkHistoryActivation();
|
|
||||||
|
|
||||||
void sendPaths();
|
void sendPaths();
|
||||||
|
|
||||||
bool contentOverlapped(const QRect &globalRect);
|
bool contentOverlapped(const QRect &globalRect);
|
||||||
|
@ -98,7 +96,7 @@ public:
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void ui_hideSettingsAndLayer(anim::type animated);
|
void ui_hideSettingsAndLayer(anim::type animated);
|
||||||
void ui_removeLayerBlackout();
|
void ui_removeLayerBlackout();
|
||||||
bool ui_isLayerShown();
|
[[nodiscard]] bool ui_isLayerShown() const;
|
||||||
bool showMediaPreview(
|
bool showMediaPreview(
|
||||||
Data::FileOrigin origin,
|
Data::FileOrigin origin,
|
||||||
not_null<DocumentData*> document);
|
not_null<DocumentData*> document);
|
||||||
|
|
|
@ -165,6 +165,8 @@ public:
|
||||||
void setInnerFocus() {
|
void setInnerFocus() {
|
||||||
doSetInnerFocus();
|
doSetInnerFocus();
|
||||||
}
|
}
|
||||||
|
virtual void checkActivation() {
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] virtual rpl::producer<int> desiredHeight() const;
|
[[nodiscard]] virtual rpl::producer<int> desiredHeight() const;
|
||||||
[[nodiscard]] virtual rpl::producer<> removeRequests() const {
|
[[nodiscard]] virtual rpl::producer<> removeRequests() const {
|
||||||
|
|
|
@ -113,7 +113,7 @@ void Controller::showAccount(
|
||||||
) | rpl::filter([=](bool idle) {
|
) | rpl::filter([=](bool idle) {
|
||||||
return !idle;
|
return !idle;
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
widget()->checkHistoryActivation();
|
widget()->checkActivation();
|
||||||
}, _sessionController->lifetime());
|
}, _sessionController->lifetime());
|
||||||
|
|
||||||
session->termsLockValue(
|
session->termsLockValue(
|
||||||
|
|
Loading…
Add table
Reference in a new issue