mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-05 00:46:08 +00:00
Handle disabling direct messages in channel.
This commit is contained in:
@@ -1067,9 +1067,20 @@ void HistoryWidget::refreshDirectMessageShown() {
|
||||
return;
|
||||
}
|
||||
const auto channel = _peer->asChannel();
|
||||
_directMessage->setVisible(channel
|
||||
&& channel->isBroadcast()
|
||||
&& channel->monoforumLink());
|
||||
const auto monoforum = channel ? channel->broadcastMonoforum() : nullptr;
|
||||
const auto visible = monoforum && !monoforum->monoforumDisabled();
|
||||
_directMessage->setVisible(visible);
|
||||
if (visible) {
|
||||
using Flags = Data::Flags<ChannelDataFlags>;
|
||||
_directMessageLifetime = monoforum->flagsValue(
|
||||
) | rpl::skip(
|
||||
1
|
||||
) | rpl::start_with_next([=](Flags::Change change) {
|
||||
if (change.diff & ChannelDataFlag::MonoforumDisabled) {
|
||||
refreshDirectMessageShown();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryWidget::refreshTopBarActiveChat() {
|
||||
@@ -2624,13 +2635,19 @@ void HistoryWidget::showHistory(
|
||||
if (const auto channel = _peer->asChannel()) {
|
||||
channel->updateFull();
|
||||
if (!channel->isBroadcast()) {
|
||||
channel->flagsValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
using Flags = Data::Flags<ChannelDataFlags>;
|
||||
channel->flagsValue() | rpl::skip(
|
||||
1
|
||||
) | rpl::start_with_next([=](Flags::Change change) {
|
||||
refreshJoinChannelText();
|
||||
if (change.diff & ChannelDataFlag::MonoforumDisabled) {
|
||||
updateCanSendMessage();
|
||||
updateSendRestriction();
|
||||
updateHistoryGeometry();
|
||||
}
|
||||
}, _list->lifetime());
|
||||
} else {
|
||||
refreshJoinChannelText();
|
||||
}
|
||||
refreshJoinChannelText();
|
||||
}
|
||||
|
||||
controller()->adaptive().changes(
|
||||
@@ -6645,7 +6662,9 @@ int HistoryWidget::countAutomaticScrollTop() {
|
||||
}
|
||||
|
||||
Data::SendError HistoryWidget::computeSendRestriction() const {
|
||||
if (!_canSendMessages && _peer->amMonoforumAdmin()) {
|
||||
if (!_canSendMessages
|
||||
&& _peer->amMonoforumAdmin()
|
||||
&& !_peer->asChannel()->monoforumDisabled()) {
|
||||
return Data::SendError({
|
||||
.text = tr::lng_monoforum_choose_to_reply(tr::now),
|
||||
.monoforumAdmin = true,
|
||||
|
Reference in New Issue
Block a user