Fix opening topic on non-existent message error display.
This commit is contained in:
parent
6258aa01b8
commit
b0f8846d12
|
@ -535,6 +535,13 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) {
|
|||
|
||||
std::optional<int> ListWidget::scrollTopForPosition(
|
||||
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 (_bar.element && !_bar.hidden && _bar.focus) {
|
||||
const auto shift = st::lineWidth + st::historyUnreadBarMargin;
|
||||
|
@ -549,6 +556,15 @@ std::optional<int> ListWidget::scrollTopForPosition(
|
|||
return height() - (_visibleBottom - _visibleTop);
|
||||
}
|
||||
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()
|
||||
|| isBelowPosition(position)
|
||||
|| isAbovePosition(position)) {
|
||||
|
@ -871,6 +887,7 @@ void ListWidget::updateAroundPositionFromNearest(int nearestIndex) {
|
|||
}
|
||||
const auto newPosition = _items[_aroundIndex]->data()->position();
|
||||
if (_aroundPosition != newPosition) {
|
||||
_initialAroundPosition = _aroundPosition;
|
||||
_aroundPosition = newPosition;
|
||||
crl::on_main(this, [=] { refreshViewer(); });
|
||||
}
|
||||
|
|
|
@ -612,6 +612,7 @@ private:
|
|||
|
||||
Data::MessagePosition _aroundPosition;
|
||||
Data::MessagePosition _shownAtPosition;
|
||||
Data::MessagePosition _initialAroundPosition;
|
||||
Context _context;
|
||||
int _aroundIndex = -1;
|
||||
int _idsLimit = kMinimalIdsLimit;
|
||||
|
|
|
@ -133,19 +133,26 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
|
|||
} // namespace
|
||||
|
||||
RepliesMemento::RepliesMemento(
|
||||
not_null<HistoryItem*> commentsItem,
|
||||
MsgId commentId)
|
||||
: RepliesMemento(commentsItem->history(), commentsItem->id, commentId) {
|
||||
if (commentId) {
|
||||
not_null<History*> history,
|
||||
MsgId rootId,
|
||||
MsgId highlightId)
|
||||
: _history(history)
|
||||
, _rootId(rootId)
|
||||
, _highlightId(highlightId) {
|
||||
if (highlightId) {
|
||||
_list.setAroundPosition({
|
||||
.fullId = FullMsgId(
|
||||
commentsItem->history()->peer->id,
|
||||
commentId),
|
||||
.fullId = FullMsgId(_history->peer->id, highlightId),
|
||||
.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) {
|
||||
_replies = topic->replies();
|
||||
if (!_list.aroundPosition()) {
|
||||
|
|
|
@ -365,11 +365,7 @@ public:
|
|||
RepliesMemento(
|
||||
not_null<History*> history,
|
||||
MsgId rootId,
|
||||
MsgId highlightId = 0)
|
||||
: _history(history)
|
||||
, _rootId(rootId)
|
||||
, _highlightId(highlightId) {
|
||||
}
|
||||
MsgId highlightId = 0);
|
||||
explicit RepliesMemento(
|
||||
not_null<HistoryItem*> commentsItem,
|
||||
MsgId commentId = 0);
|
||||
|
|
Loading…
Reference in New Issue