mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
In jump-to-date don't clear history stack.
This commit is contained in:
parent
58fb14e292
commit
bb29773090
3 changed files with 30 additions and 12 deletions
|
@ -2865,9 +2865,12 @@ void ApiWrap::readFeaturedSets() {
|
|||
}
|
||||
}
|
||||
|
||||
void ApiWrap::jumpToDate(Dialogs::Key chat, const QDate &date) {
|
||||
void ApiWrap::resolveJumpToDate(
|
||||
Dialogs::Key chat,
|
||||
const QDate &date,
|
||||
Fn<void(not_null<PeerData*>, MsgId)> callback) {
|
||||
if (const auto peer = chat.peer()) {
|
||||
jumpToHistoryDate(peer, date);
|
||||
resolveJumpToHistoryDate(peer, date, std::move(callback));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2939,20 +2942,22 @@ void ApiWrap::requestMessageAfterDate(
|
|||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date) {
|
||||
void ApiWrap::resolveJumpToHistoryDate(
|
||||
not_null<PeerData*> peer,
|
||||
const QDate &date,
|
||||
Fn<void(not_null<PeerData*>, MsgId)> callback) {
|
||||
if (const auto channel = peer->migrateTo()) {
|
||||
jumpToHistoryDate(channel, date);
|
||||
return;
|
||||
return resolveJumpToHistoryDate(channel, date, std::move(callback));
|
||||
}
|
||||
const auto jumpToDateInPeer = [=] {
|
||||
requestMessageAfterDate(peer, date, [=](MsgId resultId) {
|
||||
Ui::showPeerHistory(peer, resultId);
|
||||
callback(peer, resultId);
|
||||
});
|
||||
};
|
||||
if (const auto chat = peer->migrateFrom()) {
|
||||
requestMessageAfterDate(chat, date, [=](MsgId resultId) {
|
||||
if (resultId) {
|
||||
Ui::showPeerHistory(chat, resultId);
|
||||
callback(chat, resultId);
|
||||
} else {
|
||||
jumpToDateInPeer();
|
||||
}
|
||||
|
|
|
@ -258,7 +258,10 @@ public:
|
|||
|
||||
bool isQuitPrevent();
|
||||
|
||||
void jumpToDate(Dialogs::Key chat, const QDate &date);
|
||||
void resolveJumpToDate(
|
||||
Dialogs::Key chat,
|
||||
const QDate &date,
|
||||
Fn<void(not_null<PeerData*>, MsgId)> callback);
|
||||
|
||||
using SliceType = Data::LoadDirection;
|
||||
void requestSharedMedia(
|
||||
|
@ -445,7 +448,10 @@ private:
|
|||
void requestSavedGifs(TimeId now);
|
||||
void readFeaturedSets();
|
||||
|
||||
void jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date);
|
||||
void resolveJumpToHistoryDate(
|
||||
not_null<PeerData*> peer,
|
||||
const QDate &date,
|
||||
Fn<void(not_null<PeerData*>, MsgId)> callback);
|
||||
template <typename Callback>
|
||||
void requestMessageAfterDate(
|
||||
not_null<PeerData*> peer,
|
||||
|
|
|
@ -1441,12 +1441,19 @@ void SessionController::showCalendar(Dialogs::Key chat, QDate requestedDate) {
|
|||
button->setPointerCursor(false);
|
||||
}
|
||||
};
|
||||
const auto weak = base::make_weak(this);
|
||||
const auto jump = [=](const QDate &date) {
|
||||
const auto open = [=](not_null<PeerData*> peer, MsgId id) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(peer, SectionShow::Way::Forward, id);
|
||||
}
|
||||
};
|
||||
session().api().resolveJumpToDate(chat, date, open);
|
||||
};
|
||||
show(Box<Ui::CalendarBox>(Ui::CalendarBoxArgs{
|
||||
.month = highlighted,
|
||||
.highlighted = highlighted,
|
||||
.callback = [=](const QDate &date) {
|
||||
session().api().jumpToDate(chat, date);
|
||||
},
|
||||
.callback = [=](const QDate &date) { jump(date); },
|
||||
.minDate = minPeerDate,
|
||||
.maxDate = maxPeerDate,
|
||||
.allowsSelection = history->peer->isUser(),
|
||||
|
|
Loading…
Add table
Reference in a new issue