Replaced MainWidget::replyToItem with history element delegate.

This commit is contained in:
23rd 2021-07-26 17:37:19 +03:00
parent 65aecf16a6
commit 82165bec5e
14 changed files with 27 additions and 36 deletions

View file

@ -656,6 +656,9 @@ not_null<Ui::PathShiftGradient*> InnerWidget::elementPathShiftGradient() {
return _pathGradient.get();
}
void InnerWidget::elementReplyTo(const FullMsgId &to) {
}
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
memento->setFilter(std::move(_filter));
memento->setAdmins(std::move(_admins));

View file

@ -132,6 +132,7 @@ public:
void elementHandleViaClick(not_null<UserData*> bot) override;
bool elementIsChatWide() override;
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
void elementReplyTo(const FullMsgId &to) override;
~InnerWidget();

View file

@ -2647,6 +2647,10 @@ not_null<Ui::PathShiftGradient*> HistoryInner::elementPathShiftGradient() {
return _pathGradient.get();
}
void HistoryInner::elementReplyTo(const FullMsgId &to) {
return _widget->replyToMessage(to);
}
auto HistoryInner::getSelectionState() const
-> HistoryView::TopBarWidget::SelectedState {
auto result = HistoryView::TopBarWidget::SelectedState {};
@ -3550,6 +3554,11 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
return Instance->elementPathShiftGradient();
}
void elementReplyTo(const FullMsgId &to) override {
if (Instance) {
Instance->elementReplyTo(to);
}
}
};
static Result result;

View file

@ -109,6 +109,7 @@ public:
void elementHandleViaClick(not_null<UserData*> bot);
bool elementIsChatWide();
not_null<Ui::PathShiftGradient*> elementPathShiftGradient();
void elementReplyTo(const FullMsgId &to);
void updateBotInfo(bool recount = true);

View file

@ -169,6 +169,9 @@ auto SimpleElementDelegate::elementPathShiftGradient()
return _pathGradient.get();
}
void SimpleElementDelegate::elementReplyTo(const FullMsgId &to) {
}
TextSelection UnshiftItemSelection(
TextSelection selection,
uint16 byLength) {

View file

@ -84,6 +84,7 @@ public:
virtual void elementHandleViaClick(not_null<UserData*> bot) = 0;
virtual bool elementIsChatWide() = 0;
virtual not_null<Ui::PathShiftGradient*> elementPathShiftGradient() = 0;
virtual void elementReplyTo(const FullMsgId &to) = 0;
virtual ~ElementDelegate() {
}
@ -138,6 +139,7 @@ public:
void elementHandleViaClick(not_null<UserData*> bot) override;
bool elementIsChatWide() override;
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
void elementReplyTo(const FullMsgId &to) override;
private:
const not_null<Window::SessionController*> _controller;

View file

@ -1379,6 +1379,10 @@ not_null<Ui::PathShiftGradient*> ListWidget::elementPathShiftGradient() {
return _pathGradient.get();
}
void ListWidget::elementReplyTo(const FullMsgId &to) {
replyToMessageRequestNotify(to);
}
void ListWidget::saveState(not_null<ListMemento*> memento) {
memento->setAroundPosition(_aroundPosition);
auto state = countScrollState();

View file

@ -256,6 +256,7 @@ public:
void elementHandleViaClick(not_null<UserData*> bot) override;
bool elementIsChatWide() override;
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
void elementReplyTo(const FullMsgId &to) override;
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);

View file

@ -2417,21 +2417,9 @@ ClickHandlerPtr Message::fastReplyLink() const {
if (_fastReplyLink) {
return _fastReplyLink;
}
const auto owner = &data()->history()->owner();
const auto itemId = data()->fullId();
_fastReplyLink = std::make_shared<LambdaClickHandler>([=](
ClickContext context) {
const auto controller = ExtractController(context).value_or(nullptr);
if (!controller) {
return;
}
if (const auto item = owner->message(itemId)) {
if (const auto main = controller->content()) {
if (&main->session() == &owner->session()) {
main->replyToItem(item);
}
}
}
_fastReplyLink = std::make_shared<LambdaClickHandler>([=] {
delegate()->elementReplyTo(itemId);
});
return _fastReplyLink;
}

View file

@ -1394,15 +1394,8 @@ bool RepliesWidget::showMessage(
return true;
}
bool RepliesWidget::replyToMessage(not_null<HistoryItem*> item) {
if (item->history() != _history || item->replyToTop() != _rootId) {
return false;
}
replyToMessage(item->fullId());
return true;
}
void RepliesWidget::replyToMessage(FullMsgId itemId) {
// if (item->history() != _history || item->replyToTop() != _rootId) {
_composeControls->replyToMessage(itemId);
refreshTopBarActiveChat();
}

View file

@ -92,7 +92,6 @@ public:
PeerId peerId,
const Window::SectionShow &params,
MsgId messageId) override;
bool replyToMessage(not_null<HistoryItem*> item) override;
void setInternalState(
const QRect &geometry,

View file

@ -571,14 +571,6 @@ bool MainWidget::shareUrl(
return true;
}
void MainWidget::replyToItem(not_null<HistoryItem*> item) {
if ((!_mainSection || !_mainSection->replyToMessage(item))
&& (_history->peer() == item->history()->peer
|| _history->peer() == item->history()->peer->migrateTo())) {
_history->replyToMessage(item);
}
}
bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) {
Expects(peerId != 0);

View file

@ -168,7 +168,6 @@ public:
PeerId peerId,
const QString &url,
const QString &text);
void replyToItem(not_null<HistoryItem*> item);
bool inlineSwitchChosen(PeerId peerId, const QString &botAndQuery);
bool sendPaths(PeerId peerId);
void onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data);

View file

@ -125,10 +125,6 @@ public:
return false;
}
virtual bool replyToMessage(not_null<HistoryItem*> item) {
return false;
}
virtual bool preventsClose(Fn<void()> &&continueCallback) const {
return false;
}