Replaced MainWidget::replyToItem with history element delegate.
This commit is contained in:
parent
65aecf16a6
commit
82165bec5e
|
@ -656,6 +656,9 @@ not_null<Ui::PathShiftGradient*> InnerWidget::elementPathShiftGradient() {
|
||||||
return _pathGradient.get();
|
return _pathGradient.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InnerWidget::elementReplyTo(const FullMsgId &to) {
|
||||||
|
}
|
||||||
|
|
||||||
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
||||||
memento->setFilter(std::move(_filter));
|
memento->setFilter(std::move(_filter));
|
||||||
memento->setAdmins(std::move(_admins));
|
memento->setAdmins(std::move(_admins));
|
||||||
|
|
|
@ -132,6 +132,7 @@ public:
|
||||||
void elementHandleViaClick(not_null<UserData*> bot) override;
|
void elementHandleViaClick(not_null<UserData*> bot) override;
|
||||||
bool elementIsChatWide() override;
|
bool elementIsChatWide() override;
|
||||||
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
||||||
|
void elementReplyTo(const FullMsgId &to) override;
|
||||||
|
|
||||||
~InnerWidget();
|
~InnerWidget();
|
||||||
|
|
||||||
|
|
|
@ -2647,6 +2647,10 @@ not_null<Ui::PathShiftGradient*> HistoryInner::elementPathShiftGradient() {
|
||||||
return _pathGradient.get();
|
return _pathGradient.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HistoryInner::elementReplyTo(const FullMsgId &to) {
|
||||||
|
return _widget->replyToMessage(to);
|
||||||
|
}
|
||||||
|
|
||||||
auto HistoryInner::getSelectionState() const
|
auto HistoryInner::getSelectionState() const
|
||||||
-> HistoryView::TopBarWidget::SelectedState {
|
-> HistoryView::TopBarWidget::SelectedState {
|
||||||
auto result = HistoryView::TopBarWidget::SelectedState {};
|
auto result = HistoryView::TopBarWidget::SelectedState {};
|
||||||
|
@ -3550,6 +3554,11 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
|
||||||
|
|
||||||
return Instance->elementPathShiftGradient();
|
return Instance->elementPathShiftGradient();
|
||||||
}
|
}
|
||||||
|
void elementReplyTo(const FullMsgId &to) override {
|
||||||
|
if (Instance) {
|
||||||
|
Instance->elementReplyTo(to);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static Result result;
|
static Result result;
|
||||||
|
|
|
@ -109,6 +109,7 @@ public:
|
||||||
void elementHandleViaClick(not_null<UserData*> bot);
|
void elementHandleViaClick(not_null<UserData*> bot);
|
||||||
bool elementIsChatWide();
|
bool elementIsChatWide();
|
||||||
not_null<Ui::PathShiftGradient*> elementPathShiftGradient();
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient();
|
||||||
|
void elementReplyTo(const FullMsgId &to);
|
||||||
|
|
||||||
void updateBotInfo(bool recount = true);
|
void updateBotInfo(bool recount = true);
|
||||||
|
|
||||||
|
|
|
@ -169,6 +169,9 @@ auto SimpleElementDelegate::elementPathShiftGradient()
|
||||||
return _pathGradient.get();
|
return _pathGradient.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleElementDelegate::elementReplyTo(const FullMsgId &to) {
|
||||||
|
}
|
||||||
|
|
||||||
TextSelection UnshiftItemSelection(
|
TextSelection UnshiftItemSelection(
|
||||||
TextSelection selection,
|
TextSelection selection,
|
||||||
uint16 byLength) {
|
uint16 byLength) {
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
virtual void elementHandleViaClick(not_null<UserData*> bot) = 0;
|
virtual void elementHandleViaClick(not_null<UserData*> bot) = 0;
|
||||||
virtual bool elementIsChatWide() = 0;
|
virtual bool elementIsChatWide() = 0;
|
||||||
virtual not_null<Ui::PathShiftGradient*> elementPathShiftGradient() = 0;
|
virtual not_null<Ui::PathShiftGradient*> elementPathShiftGradient() = 0;
|
||||||
|
virtual void elementReplyTo(const FullMsgId &to) = 0;
|
||||||
|
|
||||||
virtual ~ElementDelegate() {
|
virtual ~ElementDelegate() {
|
||||||
}
|
}
|
||||||
|
@ -138,6 +139,7 @@ public:
|
||||||
void elementHandleViaClick(not_null<UserData*> bot) override;
|
void elementHandleViaClick(not_null<UserData*> bot) override;
|
||||||
bool elementIsChatWide() override;
|
bool elementIsChatWide() override;
|
||||||
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
||||||
|
void elementReplyTo(const FullMsgId &to) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
|
@ -1379,6 +1379,10 @@ not_null<Ui::PathShiftGradient*> ListWidget::elementPathShiftGradient() {
|
||||||
return _pathGradient.get();
|
return _pathGradient.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListWidget::elementReplyTo(const FullMsgId &to) {
|
||||||
|
replyToMessageRequestNotify(to);
|
||||||
|
}
|
||||||
|
|
||||||
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
||||||
memento->setAroundPosition(_aroundPosition);
|
memento->setAroundPosition(_aroundPosition);
|
||||||
auto state = countScrollState();
|
auto state = countScrollState();
|
||||||
|
|
|
@ -256,6 +256,7 @@ public:
|
||||||
void elementHandleViaClick(not_null<UserData*> bot) override;
|
void elementHandleViaClick(not_null<UserData*> bot) override;
|
||||||
bool elementIsChatWide() override;
|
bool elementIsChatWide() override;
|
||||||
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
not_null<Ui::PathShiftGradient*> elementPathShiftGradient() override;
|
||||||
|
void elementReplyTo(const FullMsgId &to) override;
|
||||||
|
|
||||||
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
||||||
|
|
||||||
|
|
|
@ -2417,21 +2417,9 @@ ClickHandlerPtr Message::fastReplyLink() const {
|
||||||
if (_fastReplyLink) {
|
if (_fastReplyLink) {
|
||||||
return _fastReplyLink;
|
return _fastReplyLink;
|
||||||
}
|
}
|
||||||
const auto owner = &data()->history()->owner();
|
|
||||||
const auto itemId = data()->fullId();
|
const auto itemId = data()->fullId();
|
||||||
_fastReplyLink = std::make_shared<LambdaClickHandler>([=](
|
_fastReplyLink = std::make_shared<LambdaClickHandler>([=] {
|
||||||
ClickContext context) {
|
delegate()->elementReplyTo(itemId);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return _fastReplyLink;
|
return _fastReplyLink;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1394,15 +1394,8 @@ bool RepliesWidget::showMessage(
|
||||||
return true;
|
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) {
|
void RepliesWidget::replyToMessage(FullMsgId itemId) {
|
||||||
|
// if (item->history() != _history || item->replyToTop() != _rootId) {
|
||||||
_composeControls->replyToMessage(itemId);
|
_composeControls->replyToMessage(itemId);
|
||||||
refreshTopBarActiveChat();
|
refreshTopBarActiveChat();
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,6 @@ public:
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
const Window::SectionShow ¶ms,
|
const Window::SectionShow ¶ms,
|
||||||
MsgId messageId) override;
|
MsgId messageId) override;
|
||||||
bool replyToMessage(not_null<HistoryItem*> item) override;
|
|
||||||
|
|
||||||
void setInternalState(
|
void setInternalState(
|
||||||
const QRect &geometry,
|
const QRect &geometry,
|
||||||
|
|
|
@ -571,14 +571,6 @@ bool MainWidget::shareUrl(
|
||||||
return true;
|
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) {
|
bool MainWidget::inlineSwitchChosen(PeerId peerId, const QString &botAndQuery) {
|
||||||
Expects(peerId != 0);
|
Expects(peerId != 0);
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,6 @@ public:
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
const QString &url,
|
const QString &url,
|
||||||
const QString &text);
|
const QString &text);
|
||||||
void replyToItem(not_null<HistoryItem*> item);
|
|
||||||
bool inlineSwitchChosen(PeerId peerId, const QString &botAndQuery);
|
bool inlineSwitchChosen(PeerId peerId, const QString &botAndQuery);
|
||||||
bool sendPaths(PeerId peerId);
|
bool sendPaths(PeerId peerId);
|
||||||
void onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data);
|
void onFilesOrForwardDrop(const PeerId &peer, const QMimeData *data);
|
||||||
|
|
|
@ -125,10 +125,6 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool replyToMessage(not_null<HistoryItem*> item) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool preventsClose(Fn<void()> &&continueCallback) const {
|
virtual bool preventsClose(Fn<void()> &&continueCallback) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue