Fix send as button refresh.
This commit is contained in:
parent
17ffebb684
commit
3c040ab5f9
|
@ -663,6 +663,7 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) {
|
||||||
updateControlsGeometry(_wrap->size());
|
updateControlsGeometry(_wrap->size());
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateFieldPlaceholder();
|
updateFieldPlaceholder();
|
||||||
|
updateSendAsButton();
|
||||||
//if (!_history) {
|
//if (!_history) {
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
|
@ -678,17 +679,6 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) {
|
||||||
_wrap.get(),
|
_wrap.get(),
|
||||||
peer->asChannel());
|
peer->asChannel());
|
||||||
}
|
}
|
||||||
if (!session().sendAsPeers().shouldChoose(peer)) {
|
|
||||||
_sendAs = nullptr;
|
|
||||||
} else if (!_sendAs) {
|
|
||||||
_sendAs = std::make_unique<Ui::SendAsButton>(
|
|
||||||
_wrap.get(),
|
|
||||||
st::sendAsButton);
|
|
||||||
Ui::SetupSendAsButton(
|
|
||||||
_sendAs.get(),
|
|
||||||
rpl::single(peer.get()),
|
|
||||||
_window);
|
|
||||||
}
|
|
||||||
session().local().readDraftsWithCursors(_history);
|
session().local().readDraftsWithCursors(_history);
|
||||||
applyDraft();
|
applyDraft();
|
||||||
}
|
}
|
||||||
|
@ -995,6 +985,7 @@ void ComposeControls::init() {
|
||||||
initField();
|
initField();
|
||||||
initTabbedSelector();
|
initTabbedSelector();
|
||||||
initSendButton();
|
initSendButton();
|
||||||
|
initSendAsButton();
|
||||||
initWriteRestriction();
|
initWriteRestriction();
|
||||||
initVoiceRecordBar();
|
initVoiceRecordBar();
|
||||||
initKeyHandler();
|
initKeyHandler();
|
||||||
|
@ -1629,6 +1620,17 @@ void ComposeControls::initSendButton() {
|
||||||
SendMenu::DefaultScheduleCallback(_wrap.get(), sendMenuType(), send));
|
SendMenu::DefaultScheduleCallback(_wrap.get(), sendMenuType(), send));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComposeControls::initSendAsButton() {
|
||||||
|
session().sendAsPeers().updated(
|
||||||
|
) | rpl::filter([=](not_null<PeerData*> peer) {
|
||||||
|
return _history && (peer == _history->peer);
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
updateSendAsButton();
|
||||||
|
updateControlsVisibility();
|
||||||
|
updateControlsGeometry(_wrap->size());
|
||||||
|
}, _wrap->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
void ComposeControls::inlineBotResolveDone(
|
void ComposeControls::inlineBotResolveDone(
|
||||||
const MTPcontacts_ResolvedPeer &result) {
|
const MTPcontacts_ResolvedPeer &result) {
|
||||||
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||||
|
@ -1936,6 +1938,23 @@ void ComposeControls::updateMessagesTTLShown() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ComposeControls::updateSendAsButton() {
|
||||||
|
Expects(_history != nullptr);
|
||||||
|
|
||||||
|
const auto peer = _history->peer;
|
||||||
|
if (!session().sendAsPeers().shouldChoose(peer)) {
|
||||||
|
_sendAs = nullptr;
|
||||||
|
} else if (!_sendAs) {
|
||||||
|
_sendAs = std::make_unique<Ui::SendAsButton>(
|
||||||
|
_wrap.get(),
|
||||||
|
st::sendAsButton);
|
||||||
|
Ui::SetupSendAsButton(
|
||||||
|
_sendAs.get(),
|
||||||
|
rpl::single(peer.get()),
|
||||||
|
_window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ComposeControls::paintBackground(QRect clip) {
|
void ComposeControls::paintBackground(QRect clip) {
|
||||||
Painter p(_wrap.get());
|
Painter p(_wrap.get());
|
||||||
|
|
||||||
|
|
|
@ -197,6 +197,7 @@ private:
|
||||||
void initField();
|
void initField();
|
||||||
void initTabbedSelector();
|
void initTabbedSelector();
|
||||||
void initSendButton();
|
void initSendButton();
|
||||||
|
void initSendAsButton();
|
||||||
void initWebpageProcess();
|
void initWebpageProcess();
|
||||||
void initWriteRestriction();
|
void initWriteRestriction();
|
||||||
void initVoiceRecordBar();
|
void initVoiceRecordBar();
|
||||||
|
@ -205,6 +206,7 @@ private:
|
||||||
void updateSubmitSettings();
|
void updateSubmitSettings();
|
||||||
void updateSendButtonType();
|
void updateSendButtonType();
|
||||||
void updateMessagesTTLShown();
|
void updateMessagesTTLShown();
|
||||||
|
void updateSendAsButton();
|
||||||
void updateHeight();
|
void updateHeight();
|
||||||
void updateWrappingVisibility();
|
void updateWrappingVisibility();
|
||||||
void updateControlsVisibility();
|
void updateControlsVisibility();
|
||||||
|
|
Loading…
Reference in New Issue