mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
parent
03a5619d61
commit
0cb8f2cc85
2 changed files with 51 additions and 6 deletions
|
@ -50,6 +50,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/format_values.h"
|
||||
#include "ui/controls/emoji_button.h"
|
||||
#include "ui/controls/send_button.h"
|
||||
#include "ui/special_buttons.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
@ -663,6 +664,10 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) {
|
|||
if (!channel->mgInfo->botStatus) {
|
||||
session().api().requestBots(channel);
|
||||
}
|
||||
} else if (hasSilentBroadcastToggle()) {
|
||||
_silent = std::make_unique<Ui::SilentToggle>(
|
||||
_wrap.get(),
|
||||
peer->asChannel());
|
||||
}
|
||||
session().local().readDraftsWithCursors(_history);
|
||||
applyDraft();
|
||||
|
@ -1297,6 +1302,17 @@ void ComposeControls::updateFieldPlaceholder() {
|
|||
updateSendButtonType();
|
||||
}
|
||||
|
||||
void ComposeControls::updateSilentBroadcast() {
|
||||
if (!_silent || !_history) {
|
||||
return;
|
||||
}
|
||||
const auto &peer = _history->peer;
|
||||
if (!session().data().notifySilentPostsUnknown(peer)) {
|
||||
_silent->setChecked(session().data().notifySilentPosts(peer));
|
||||
updateFieldPlaceholder();
|
||||
}
|
||||
}
|
||||
|
||||
void ComposeControls::fieldChanged() {
|
||||
if (!_inlineBot
|
||||
&& !_header->isEditingMessage()
|
||||
|
@ -1720,14 +1736,15 @@ void ComposeControls::finishAnimating() {
|
|||
|
||||
void ComposeControls::updateControlsGeometry(QSize size) {
|
||||
// _attachToggle -- _inlineResults ------ _tabbedPanel -- _fieldBarCancel
|
||||
// (_attachDocument|_attachPhoto) _field _botCommandStart _tabbedSelectorToggle _send
|
||||
// (_attachDocument|_attachPhoto) _field (_silent|_botCommandStart) _tabbedSelectorToggle _send
|
||||
|
||||
const auto fieldWidth = size.width()
|
||||
- _attachToggle->width()
|
||||
- st::historySendRight
|
||||
- _send->width()
|
||||
- _tabbedSelectorToggle->width()
|
||||
- (_botCommandShown ? _botCommandStart->width() : 0);
|
||||
- (_botCommandShown ? _botCommandStart->width() : 0)
|
||||
- (_silent ? _silent->width() : 0);
|
||||
{
|
||||
const auto oldFieldHeight = _field->height();
|
||||
_field->resizeToWidth(fieldWidth);
|
||||
|
@ -1758,6 +1775,9 @@ void ComposeControls::updateControlsGeometry(QSize size) {
|
|||
_tabbedSelectorToggle->moveToRight(right, buttonsTop);
|
||||
right += _tabbedSelectorToggle->width();
|
||||
_botCommandStart->moveToRight(right, buttonsTop);
|
||||
if (_silent) {
|
||||
_silent->moveToRight(right, buttonsTop);
|
||||
}
|
||||
|
||||
_voiceRecordBar->resizeToWidth(size.width());
|
||||
_voiceRecordBar->moveToLeft(
|
||||
|
@ -2155,12 +2175,20 @@ void ComposeControls::initWebpageProcess() {
|
|||
|
||||
session().changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::Rights
|
||||
| Data::PeerUpdate::Flag::Notifications
|
||||
) | rpl::filter([=](const Data::PeerUpdate &update) {
|
||||
return (update.peer.get() == peer);
|
||||
}) | rpl::start_with_next([=] {
|
||||
}) | rpl::map([](const Data::PeerUpdate &update) {
|
||||
return update.flags;
|
||||
}) | rpl::start_with_next([=](Data::PeerUpdate::Flags flags) {
|
||||
if (flags & Data::PeerUpdate::Flag::Rights) {
|
||||
checkPreview();
|
||||
updateStickersByEmoji();
|
||||
updateFieldPlaceholder();
|
||||
}
|
||||
if (flags & Data::PeerUpdate::Flag::Notifications) {
|
||||
updateSilentBroadcast();
|
||||
}
|
||||
}, lifetime);
|
||||
|
||||
base::ObservableViewer(
|
||||
|
@ -2263,6 +2291,18 @@ bool ComposeControls::preventsClose(Fn<void()> &&continueCallback) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ComposeControls::hasSilentBroadcastToggle() const {
|
||||
if (!_history) {
|
||||
return false;
|
||||
}
|
||||
const auto &peer = _history->peer;
|
||||
return peer
|
||||
&& peer->isChannel()
|
||||
&& !peer->isMegagroup()
|
||||
&& peer->canWrite()
|
||||
&& !session().data().notifySilentPostsUnknown(peer);
|
||||
}
|
||||
|
||||
void ComposeControls::updateInlineBotQuery() {
|
||||
if (!_history) {
|
||||
return;
|
||||
|
|
|
@ -49,6 +49,7 @@ namespace Ui {
|
|||
class SendButton;
|
||||
class IconButton;
|
||||
class EmojiButton;
|
||||
class SilentToggle;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Main {
|
||||
|
@ -218,6 +219,7 @@ private:
|
|||
void checkAutocomplete();
|
||||
void updateStickersByEmoji();
|
||||
void updateFieldPlaceholder();
|
||||
void updateSilentBroadcast();
|
||||
void editMessage(not_null<HistoryItem*> item);
|
||||
|
||||
void escape();
|
||||
|
@ -235,6 +237,8 @@ private:
|
|||
void clearInlineBot();
|
||||
void inlineBotChanged();
|
||||
|
||||
bool hasSilentBroadcastToggle() const;
|
||||
|
||||
// Look in the _field for the inline bot and query string.
|
||||
void updateInlineBotQuery();
|
||||
|
||||
|
@ -279,6 +283,7 @@ private:
|
|||
const not_null<Ui::EmojiButton*> _tabbedSelectorToggle;
|
||||
const not_null<Ui::InputField*> _field;
|
||||
const not_null<Ui::IconButton*> _botCommandStart;
|
||||
std::unique_ptr<Ui::SilentToggle> _silent;
|
||||
|
||||
std::unique_ptr<InlineBots::Layout::Widget> _inlineResults;
|
||||
std::unique_ptr<ChatHelpers::TabbedPanel> _tabbedPanel;
|
||||
|
|
Loading…
Add table
Reference in a new issue