mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix opening topic on non-existent message error display.
This commit is contained in:
parent
6258aa01b8
commit
b0f8846d12
4 changed files with 33 additions and 12 deletions
|
@ -535,6 +535,13 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
|
||||||
|
|
||||||
std::optional<int> ListWidget::scrollTopForPosition(
|
std::optional<int> ListWidget::scrollTopForPosition(
|
||||||
Data::MessagePosition position) const {
|
Data::MessagePosition position) const {
|
||||||
|
auto messageUnknown = !position.date && position.fullId;
|
||||||
|
if (messageUnknown) {
|
||||||
|
if (const auto item = session().data().message(position.fullId)) {
|
||||||
|
position = item->position();
|
||||||
|
messageUnknown = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (position == Data::UnreadMessagePosition) {
|
if (position == Data::UnreadMessagePosition) {
|
||||||
if (_bar.element && !_bar.hidden && _bar.focus) {
|
if (_bar.element && !_bar.hidden && _bar.focus) {
|
||||||
const auto shift = st::lineWidth + st::historyUnreadBarMargin;
|
const auto shift = st::lineWidth + st::historyUnreadBarMargin;
|
||||||
|
@ -549,6 +556,15 @@ std::optional<int> ListWidget::scrollTopForPosition(
|
||||||
return height() - (_visibleBottom - _visibleTop);
|
return height() - (_visibleBottom - _visibleTop);
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
} else if (!_items.empty()
|
||||||
|
&& (_aroundPosition == position
|
||||||
|
|| _initialAroundPosition == position)
|
||||||
|
&& messageUnknown) {
|
||||||
|
if (_refreshingViewer) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
const auto available = _visibleBottom - _visibleTop;
|
||||||
|
return std::max((height() / 2) - available / 2, 0);
|
||||||
} else if (_items.empty()
|
} else if (_items.empty()
|
||||||
|| isBelowPosition(position)
|
|| isBelowPosition(position)
|
||||||
|| isAbovePosition(position)) {
|
|| isAbovePosition(position)) {
|
||||||
|
@ -871,6 +887,7 @@ void ListWidget::updateAroundPositionFromNearest(int nearestIndex) {
|
||||||
}
|
}
|
||||||
const auto newPosition = _items[_aroundIndex]->data()->position();
|
const auto newPosition = _items[_aroundIndex]->data()->position();
|
||||||
if (_aroundPosition != newPosition) {
|
if (_aroundPosition != newPosition) {
|
||||||
|
_initialAroundPosition = _aroundPosition;
|
||||||
_aroundPosition = newPosition;
|
_aroundPosition = newPosition;
|
||||||
crl::on_main(this, [=] { refreshViewer(); });
|
crl::on_main(this, [=] { refreshViewer(); });
|
||||||
}
|
}
|
||||||
|
|
|
@ -612,6 +612,7 @@ private:
|
||||||
|
|
||||||
Data::MessagePosition _aroundPosition;
|
Data::MessagePosition _aroundPosition;
|
||||||
Data::MessagePosition _shownAtPosition;
|
Data::MessagePosition _shownAtPosition;
|
||||||
|
Data::MessagePosition _initialAroundPosition;
|
||||||
Context _context;
|
Context _context;
|
||||||
int _aroundIndex = -1;
|
int _aroundIndex = -1;
|
||||||
int _idsLimit = kMinimalIdsLimit;
|
int _idsLimit = kMinimalIdsLimit;
|
||||||
|
|
|
@ -133,19 +133,26 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
RepliesMemento::RepliesMemento(
|
RepliesMemento::RepliesMemento(
|
||||||
not_null<HistoryItem*> commentsItem,
|
not_null<History*> history,
|
||||||
MsgId commentId)
|
MsgId rootId,
|
||||||
: RepliesMemento(commentsItem->history(), commentsItem->id, commentId) {
|
MsgId highlightId)
|
||||||
if (commentId) {
|
: _history(history)
|
||||||
|
, _rootId(rootId)
|
||||||
|
, _highlightId(highlightId) {
|
||||||
|
if (highlightId) {
|
||||||
_list.setAroundPosition({
|
_list.setAroundPosition({
|
||||||
.fullId = FullMsgId(
|
.fullId = FullMsgId(_history->peer->id, highlightId),
|
||||||
commentsItem->history()->peer->id,
|
|
||||||
commentId),
|
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RepliesMemento::RepliesMemento(
|
||||||
|
not_null<HistoryItem*> commentsItem,
|
||||||
|
MsgId commentId)
|
||||||
|
: RepliesMemento(commentsItem->history(), commentsItem->id, commentId) {
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesMemento::setFromTopic(not_null<Data::ForumTopic*> topic) {
|
void RepliesMemento::setFromTopic(not_null<Data::ForumTopic*> topic) {
|
||||||
_replies = topic->replies();
|
_replies = topic->replies();
|
||||||
if (!_list.aroundPosition()) {
|
if (!_list.aroundPosition()) {
|
||||||
|
|
|
@ -365,11 +365,7 @@ public:
|
||||||
RepliesMemento(
|
RepliesMemento(
|
||||||
not_null<History*> history,
|
not_null<History*> history,
|
||||||
MsgId rootId,
|
MsgId rootId,
|
||||||
MsgId highlightId = 0)
|
MsgId highlightId = 0);
|
||||||
: _history(history)
|
|
||||||
, _rootId(rootId)
|
|
||||||
, _highlightId(highlightId) {
|
|
||||||
}
|
|
||||||
explicit RepliesMemento(
|
explicit RepliesMemento(
|
||||||
not_null<HistoryItem*> commentsItem,
|
not_null<HistoryItem*> commentsItem,
|
||||||
MsgId commentId = 0);
|
MsgId commentId = 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue