2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Pass SessionNavigation to some boxes.

This commit is contained in:
John Preston
2019-07-25 20:55:11 +02:00
parent 137fa0378c
commit bacaf805b5
54 changed files with 601 additions and 233 deletions

View File

@@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h"
#include "history/history_item.h"
#include "mainwidget.h"
#include "window/window_session_controller.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_media_types.h"
@@ -211,8 +212,16 @@ void BoxController::Row::stopLastActionRipple() {
}
}
BoxController::BoxController(not_null<Window::SessionController*> window)
: _window(window) {
}
Main::Session &BoxController::session() const {
return _window->session();
}
void BoxController::prepare() {
Auth().data().itemRemoved(
session().data().itemRemoved(
) | rpl::start_with_next([=](not_null<const HistoryItem*> item) {
if (const auto row = rowForItem(item)) {
row->itemRemoved(item);
@@ -226,7 +235,7 @@ void BoxController::prepare() {
}
}, lifetime());
subscribe(Current().newServiceMessage(), [=](FullMsgId msgId) {
if (const auto item = Auth().data().message(msgId)) {
if (const auto item = session().data().message(msgId)) {
insertRow(item, InsertWay::Prepend);
}
});
@@ -261,8 +270,8 @@ void BoxController::loadMoreRows() {
_loadRequestId = 0;
auto handleResult = [&](auto &data) {
Auth().data().processUsers(data.vusers());
Auth().data().processChats(data.vchats());
session().data().processUsers(data.vusers());
session().data().processChats(data.vchats());
receivedCalls(data.vmessages().v);
};
@@ -310,8 +319,8 @@ void BoxController::receivedCalls(const QVector<MTPMessage> &result) {
for (const auto &message : result) {
const auto msgId = IdFromMessage(message);
const auto peerId = PeerFromMessage(message);
if (const auto peer = Auth().data().peerLoaded(peerId)) {
const auto item = Auth().data().addNewMessage(
if (const auto peer = session().data().peerLoaded(peerId)) {
const auto item = session().data().addNewMessage(
message,
NewMessageType::Existing);
insertRow(item, InsertWay::Append);

View File

@@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peer_list_box.h"
namespace Window {
class SessionController;
} // namespace Window
namespace Calls {
class BoxController
@@ -16,6 +20,9 @@ class BoxController
, private base::Subscriber
, private MTP::Sender {
public:
explicit BoxController(not_null<Window::SessionController*> window);
Main::Session &session() const override;
void prepare() override;
void rowClicked(not_null<PeerListRow*> row) override;
void rowActionClicked(not_null<PeerListRow*> row) override;
@@ -36,6 +43,8 @@ private:
std::unique_ptr<PeerListRow> createRow(
not_null<HistoryItem*> item) const;
const not_null<Window::SessionController*> _window;
MsgId _offsetId = 0;
mtpRequestId _loadRequestId = 0;
bool _allLoaded = false;

View File

@@ -446,7 +446,7 @@ bool Call::handleUpdate(const MTPPhoneCall &call) {
}
}
if (data.is_need_rating() && _id && _accessHash) {
Ui::show(Box<RateCallBox>(_id, _accessHash));
Ui::show(Box<RateCallBox>(&Auth(), _id, _accessHash));
}
const auto reason = data.vreason();
if (reason && reason->type() == mtpc_phoneCallDiscardReasonDisconnect) {