mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-29 13:39:06 +00:00
Allow forwarding polls to monoforums.
This commit is contained in:
parent
6c80d443b9
commit
dd8fdfc3d4
@ -156,12 +156,6 @@ bool CanSendAnyOf(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (const auto channel = peer->asChannel()) {
|
} else if (const auto channel = peer->asChannel()) {
|
||||||
if (channel->isMonoforum()) {
|
|
||||||
rights &= ~ChatRestriction::SendPolls;
|
|
||||||
if (!rights) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
using Flag = ChannelDataFlag;
|
using Flag = ChannelDataFlag;
|
||||||
const auto allowed = channel->amIn()
|
const auto allowed = channel->amIn()
|
||||||
|| ((channel->flags() & Flag::HasLink)
|
|| ((channel->flags() & Flag::HasLink)
|
||||||
|
@ -668,6 +668,8 @@ bool PeerData::canCreatePolls() const {
|
|||||||
&& !user->isSupport()
|
&& !user->isSupport()
|
||||||
&& !user->isRepliesChat()
|
&& !user->isRepliesChat()
|
||||||
&& !user->isVerifyCodes());
|
&& !user->isVerifyCodes());
|
||||||
|
} else if (isMonoforum()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return Data::CanSend(this, ChatRestriction::SendPolls);
|
return Data::CanSend(this, ChatRestriction::SendPolls);
|
||||||
}
|
}
|
||||||
|
@ -274,12 +274,6 @@ inline auto DefaultRestrictionValue(
|
|||||||
| Flag::Forbidden
|
| Flag::Forbidden
|
||||||
| Flag::Creator
|
| Flag::Creator
|
||||||
| Flag::Broadcast;
|
| Flag::Broadcast;
|
||||||
if (channel->isMonoforum()) {
|
|
||||||
rights &= ~ChatRestriction::SendPolls;
|
|
||||||
if (!rights) {
|
|
||||||
return rpl::single(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rpl::combine(
|
return rpl::combine(
|
||||||
PeerFlagsValue(channel, mask),
|
PeerFlagsValue(channel, mask),
|
||||||
AdminRightValue(
|
AdminRightValue(
|
||||||
|
@ -1464,11 +1464,7 @@ bool InnerWidget::isRowActive(
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else if (const auto sublist = entry.key.sublist()) {
|
} else if (const auto sublist = entry.key.sublist()) {
|
||||||
if (!sublist->parentChat()) {
|
return key.history() && key.history() == sublist->owningHistory();
|
||||||
// In case we're viewing a Saved Messages sublist,
|
|
||||||
// we want to highlight the Saved Messages row as active.
|
|
||||||
return key.history() && key.peer()->isSelf();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1909,9 +1905,14 @@ RowDescriptor InnerWidget::computeChatPreviewRow() const {
|
|||||||
auto result = computeChosenRow();
|
auto result = computeChosenRow();
|
||||||
if (const auto peer = result.key.peer()) {
|
if (const auto peer = result.key.peer()) {
|
||||||
const auto topicId = _pressedTopicJump
|
const auto topicId = _pressedTopicJump
|
||||||
? _pressedTopicJumpRootId // #TODO monoforums
|
? _pressedTopicJumpRootId
|
||||||
: 0;
|
: MsgId();
|
||||||
if (const auto topic = peer->forumTopicFor(topicId)) {
|
const auto sublistPeerId = _pressedTopicJump
|
||||||
|
? _pressedSublistJumpPeerId
|
||||||
|
: PeerId();
|
||||||
|
if (const auto sublist = peer->monoforumSublistFor(sublistPeerId)) {
|
||||||
|
return { sublist, FullMsgId() };
|
||||||
|
} else if (const auto topic = peer->forumTopicFor(topicId)) {
|
||||||
return { topic, FullMsgId() };
|
return { topic, FullMsgId() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2422,6 +2423,7 @@ void InnerWidget::mousePressReleased(
|
|||||||
auto collapsedPressed = _collapsedPressed;
|
auto collapsedPressed = _collapsedPressed;
|
||||||
setCollapsedPressed(-1);
|
setCollapsedPressed(-1);
|
||||||
const auto pressedTopicRootId = _pressedTopicJumpRootId;
|
const auto pressedTopicRootId = _pressedTopicJumpRootId;
|
||||||
|
const auto pressedSublistPeerId = _pressedSublistJumpPeerId;
|
||||||
const auto pressedTopicJump = _pressedTopicJump;
|
const auto pressedTopicJump = _pressedTopicJump;
|
||||||
const auto pressedRightButton = _pressedRightButton;
|
const auto pressedRightButton = _pressedRightButton;
|
||||||
auto pressed = _pressed;
|
auto pressed = _pressed;
|
||||||
@ -2505,7 +2507,10 @@ void InnerWidget::mousePressReleased(
|
|||||||
} else if (pressedRightButton && peerSearchPressed >= 0) {
|
} else if (pressedRightButton && peerSearchPressed >= 0) {
|
||||||
showSponsoredMenu(peerSearchPressed, globalPosition);
|
showSponsoredMenu(peerSearchPressed, globalPosition);
|
||||||
} else {
|
} else {
|
||||||
chooseRow(modifiers, pressedTopicRootId);
|
chooseRow(
|
||||||
|
modifiers,
|
||||||
|
pressedTopicRootId,
|
||||||
|
pressedSublistPeerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2557,6 +2562,9 @@ void InnerWidget::setPressed(
|
|||||||
: nullptr;
|
: nullptr;
|
||||||
const auto item = history ? history->chatListMessage() : nullptr;
|
const auto item = history ? history->chatListMessage() : nullptr;
|
||||||
_pressedTopicJumpRootId = item ? item->topicRootId() : MsgId();
|
_pressedTopicJumpRootId = item ? item->topicRootId() : MsgId();
|
||||||
|
_pressedSublistJumpPeerId = item
|
||||||
|
? item->sublistPeerId()
|
||||||
|
: PeerId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2603,6 +2611,9 @@ void InnerWidget::setFilteredPressed(
|
|||||||
: nullptr;
|
: nullptr;
|
||||||
const auto item = history ? history->chatListMessage() : nullptr;
|
const auto item = history ? history->chatListMessage() : nullptr;
|
||||||
_pressedTopicJumpRootId = item ? item->topicRootId() : MsgId();
|
_pressedTopicJumpRootId = item ? item->topicRootId() : MsgId();
|
||||||
|
_pressedSublistJumpPeerId = item
|
||||||
|
? item->sublistPeerId()
|
||||||
|
: PeerId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4763,7 +4774,8 @@ bool InnerWidget::isUserpicPressOnWide() const {
|
|||||||
|
|
||||||
bool InnerWidget::chooseRow(
|
bool InnerWidget::chooseRow(
|
||||||
Qt::KeyboardModifiers modifiers,
|
Qt::KeyboardModifiers modifiers,
|
||||||
MsgId pressedTopicRootId) {
|
MsgId pressedTopicRootId,
|
||||||
|
PeerId pressedSublistPeerId) {
|
||||||
if (chooseHashtag()) {
|
if (chooseHashtag()) {
|
||||||
return true;
|
return true;
|
||||||
} else if (_selectedMorePosts) {
|
} else if (_selectedMorePosts) {
|
||||||
@ -4805,12 +4817,9 @@ bool InnerWidget::chooseRow(
|
|||||||
if (!chosen.message.fullId) {
|
if (!chosen.message.fullId) {
|
||||||
if (const auto history = chosen.key.history()) {
|
if (const auto history = chosen.key.history()) {
|
||||||
if (history->peer->forum()) {
|
if (history->peer->forum()) {
|
||||||
if (pressedTopicRootId) {
|
chosen.topicJumpRootId = pressedTopicRootId;
|
||||||
chosen.message.fullId = {
|
} else if (history->peer->amMonoforumAdmin()) {
|
||||||
history->peer->id,
|
chosen.sublistJumpPeerId = pressedSublistPeerId;
|
||||||
pressedTopicRootId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,8 @@ enum class ChatTypeFilter : uchar;
|
|||||||
struct ChosenRow {
|
struct ChosenRow {
|
||||||
Key key;
|
Key key;
|
||||||
Data::MessagePosition message;
|
Data::MessagePosition message;
|
||||||
|
MsgId topicJumpRootId;
|
||||||
|
PeerId sublistJumpPeerId;
|
||||||
QByteArray sponsoredRandomId;
|
QByteArray sponsoredRandomId;
|
||||||
bool userpicClick : 1 = false;
|
bool userpicClick : 1 = false;
|
||||||
bool filteredRow : 1 = false;
|
bool filteredRow : 1 = false;
|
||||||
@ -163,7 +165,8 @@ public:
|
|||||||
void chatPreviewShown(bool shown, RowDescriptor row = {});
|
void chatPreviewShown(bool shown, RowDescriptor row = {});
|
||||||
bool chooseRow(
|
bool chooseRow(
|
||||||
Qt::KeyboardModifiers modifiers = {},
|
Qt::KeyboardModifiers modifiers = {},
|
||||||
MsgId pressedTopicRootId = {});
|
MsgId pressedTopicRootId = {},
|
||||||
|
PeerId pressedSublistPeerId = {});
|
||||||
|
|
||||||
void scrollToEntry(const RowDescriptor &entry);
|
void scrollToEntry(const RowDescriptor &entry);
|
||||||
|
|
||||||
@ -543,6 +546,7 @@ private:
|
|||||||
Row *_selected = nullptr;
|
Row *_selected = nullptr;
|
||||||
Row *_pressed = nullptr;
|
Row *_pressed = nullptr;
|
||||||
MsgId _pressedTopicJumpRootId;
|
MsgId _pressedTopicJumpRootId;
|
||||||
|
PeerId _pressedSublistJumpPeerId;
|
||||||
bool _selectedTopicJump = false;
|
bool _selectedTopicJump = false;
|
||||||
bool _pressedTopicJump = false;
|
bool _pressedTopicJump = false;
|
||||||
|
|
||||||
|
@ -860,7 +860,10 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||||||
|
|
||||||
const auto history = row.key.history();
|
const auto history = row.key.history();
|
||||||
const auto topicJump = history
|
const auto topicJump = history
|
||||||
? history->peer->forumTopicFor(row.message.fullId.msg)
|
? history->peer->forumTopicFor(row.topicJumpRootId)
|
||||||
|
: nullptr;
|
||||||
|
const auto sublistJump = history
|
||||||
|
? history->peer->monoforumSublistFor(row.sublistJumpPeerId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
if (topicJump) {
|
if (topicJump) {
|
||||||
@ -880,6 +883,16 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||||||
Window::SectionShow::Way::ClearStack);
|
Window::SectionShow::Way::ClearStack);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
} else if (sublistJump) {
|
||||||
|
if (row.newWindow) {
|
||||||
|
controller()->showInNewWindow(Window::SeparateId(sublistJump));
|
||||||
|
} else {
|
||||||
|
controller()->showThread(
|
||||||
|
sublistJump,
|
||||||
|
ShowAtUnreadMsgId,
|
||||||
|
Window::SectionShow::Way::ClearStack);
|
||||||
|
}
|
||||||
|
return;
|
||||||
} else if (const auto topic = row.key.topic()) {
|
} else if (const auto topic = row.key.topic()) {
|
||||||
auto params = Window::SectionShow(
|
auto params = Window::SectionShow(
|
||||||
Window::SectionShow::Way::ClearStack);
|
Window::SectionShow::Way::ClearStack);
|
||||||
|
@ -267,11 +267,18 @@ int MessageView::countWidth() const {
|
|||||||
auto result = 0;
|
auto result = 0;
|
||||||
if (!_senderCache.isEmpty()) {
|
if (!_senderCache.isEmpty()) {
|
||||||
result += _senderCache.maxWidth();
|
result += _senderCache.maxWidth();
|
||||||
if (!_imagesCache.empty()) {
|
if (!_imagesCache.empty() && !_leftIcon) {
|
||||||
result += st::dialogsMiniPreviewSkip
|
result += st::dialogsMiniPreviewSkip
|
||||||
+ st::dialogsMiniPreviewRight;
|
+ st::dialogsMiniPreviewRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (_leftIcon) {
|
||||||
|
const auto w = _leftIcon->icon.icon.width();
|
||||||
|
result += w
|
||||||
|
+ (_imagesCache.empty()
|
||||||
|
? _leftIcon->skipText
|
||||||
|
: _leftIcon->skipMedia);
|
||||||
|
}
|
||||||
if (!_imagesCache.empty()) {
|
if (!_imagesCache.empty()) {
|
||||||
result += (_imagesCache.size()
|
result += (_imagesCache.size()
|
||||||
* (st::dialogsMiniPreview + st::dialogsMiniPreviewSkip))
|
* (st::dialogsMiniPreview + st::dialogsMiniPreviewSkip))
|
||||||
|
@ -2126,7 +2126,10 @@ void HistoryWidget::setupDirectMessageButton() {
|
|||||||
}, _directMessage->lifetime());
|
}, _directMessage->lifetime());
|
||||||
_directMessage->setClickedCallback([=] {
|
_directMessage->setClickedCallback([=] {
|
||||||
if (const auto channel = _peer ? _peer->asChannel() : nullptr) {
|
if (const auto channel = _peer ? _peer->asChannel() : nullptr) {
|
||||||
if (const auto monoforum = channel->monoforumLink()) {
|
if (channel->invitePeekExpires()) {
|
||||||
|
controller()->showToast(
|
||||||
|
tr::lng_channel_invite_private(tr::now));
|
||||||
|
} else if (const auto monoforum = channel->monoforumLink()) {
|
||||||
controller()->showPeerHistory(
|
controller()->showPeerHistory(
|
||||||
monoforum,
|
monoforum,
|
||||||
Window::SectionShow::Way::Forward);
|
Window::SectionShow::Way::Forward);
|
||||||
@ -6038,7 +6041,7 @@ bool HistoryWidget::showSendingFilesError(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgId HistoryWidget::resolveReplyToTopicRootId() { // #TODO monoforums
|
MsgId HistoryWidget::resolveReplyToTopicRootId() {
|
||||||
Expects(_peer != nullptr);
|
Expects(_peer != nullptr);
|
||||||
|
|
||||||
const auto replyToInfo = replyTo();
|
const auto replyToInfo = replyTo();
|
||||||
|
@ -660,6 +660,7 @@ bool SubsectionTabs::switchTo(
|
|||||||
}
|
}
|
||||||
_shadow->setParent(parent);
|
_shadow->setParent(parent);
|
||||||
_shadow->show();
|
_shadow->show();
|
||||||
|
_refreshed.fire({});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user