mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Don't allow reply to changelog stories.
This commit is contained in:
parent
0183790518
commit
6eaa192f51
3 changed files with 53 additions and 34 deletions
|
@ -96,7 +96,6 @@ private:
|
|||
|
||||
const not_null<Controller*> _controller;
|
||||
std::unique_ptr<Ui::RpWidget> _bg;
|
||||
std::unique_ptr<Ui::RpWidget> _reply;
|
||||
std::unique_ptr<Ui::FlatLabel> _text;
|
||||
std::unique_ptr<Ui::RoundButton> _button;
|
||||
Ui::RoundRect _bgRound;
|
||||
|
@ -172,32 +171,9 @@ void Controller::Unsupported::setup(not_null<UserData*> user) {
|
|||
_bgRound.paint(p, _bg->rect());
|
||||
}, _bg->lifetime());
|
||||
|
||||
if (!user->isSelf()) {
|
||||
_reply = std::make_unique<Ui::RpWidget>(wrap);
|
||||
_reply->show();
|
||||
_reply->paintRequest() | rpl::start_with_next([=] {
|
||||
auto p = QPainter(_reply.get());
|
||||
_bgRound.paint(p, _reply->rect());
|
||||
|
||||
p.setPen(st::storiesComposeGrayText);
|
||||
p.setFont(st::normalFont);
|
||||
p.drawText(
|
||||
_reply->rect(),
|
||||
tr::lng_stories_cant_reply(tr::now),
|
||||
style::al_center);
|
||||
}, _reply->lifetime());
|
||||
}
|
||||
|
||||
_controller->layoutValue(
|
||||
) | rpl::start_with_next([=](const Layout &layout) {
|
||||
_bg->setGeometry(layout.content);
|
||||
if (_reply) {
|
||||
const auto height = st::storiesComposeControls.attach.height;
|
||||
const auto position = layout.controlsBottomPosition
|
||||
- QPoint(0, height);
|
||||
_reply->setGeometry(
|
||||
{ position, QSize{ layout.controlsWidth, height } });
|
||||
}
|
||||
}, _bg->lifetime());
|
||||
|
||||
_text = std::make_unique<Ui::FlatLabel>(
|
||||
|
@ -1141,7 +1117,6 @@ void Controller::rebuildCachedSourcesList(
|
|||
} else {
|
||||
// All that go before the current push to front.
|
||||
for (auto before = index; before > 0;) {
|
||||
--before;
|
||||
const auto peerId = lists[--before].id;
|
||||
if (!ranges::contains(_cachedSourcesList, peerId)) {
|
||||
_cachedSourcesList.insert(
|
||||
|
@ -1160,12 +1135,8 @@ void Controller::rebuildCachedSourcesList(
|
|||
}
|
||||
|
||||
Ensures(_cachedSourcesList.size() == lists.size());
|
||||
Ensures(ranges::equal(
|
||||
lists,
|
||||
_cachedSourcesList,
|
||||
ranges::equal_to(),
|
||||
&Data::StoriesSourceInfo::id));
|
||||
Ensures(_cachedSourceIndex >= 0 && _cachedSourceIndex < _cachedSourcesList.size());
|
||||
Ensures(_cachedSourceIndex >= 0
|
||||
&& _cachedSourceIndex < _cachedSourcesList.size());
|
||||
}
|
||||
|
||||
void Controller::refreshViewsFromData() {
|
||||
|
|
|
@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "storage/storage_account.h"
|
||||
#include "storage/storage_media_prepare.h"
|
||||
#include "ui/chat/attach/attach_prepare.h"
|
||||
#include "ui/round_rect.h"
|
||||
#include "window/section_widget.h"
|
||||
#include "styles/style_boxes.h" // sendMediaPreviewSize.
|
||||
#include "styles/style_chat_helpers.h"
|
||||
|
@ -42,6 +43,35 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Media::Stories {
|
||||
|
||||
class ReplyArea::Cant final : public Ui::RpWidget {
|
||||
public:
|
||||
explicit Cant(not_null<QWidget*> parent);
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
Ui::RoundRect _bg;
|
||||
|
||||
};
|
||||
|
||||
ReplyArea::Cant::Cant(not_null<QWidget*> parent)
|
||||
: RpWidget(parent)
|
||||
, _bg(st::storiesRadius, st::storiesComposeBg) {
|
||||
show();
|
||||
}
|
||||
|
||||
void ReplyArea::Cant::paintEvent(QPaintEvent *e) {
|
||||
auto p = QPainter(this);
|
||||
_bg.paint(p, rect());
|
||||
|
||||
p.setPen(st::storiesComposeGrayText);
|
||||
p.setFont(st::normalFont);
|
||||
p.drawText(
|
||||
rect(),
|
||||
tr::lng_stories_cant_reply(tr::now),
|
||||
style::al_center);
|
||||
}
|
||||
|
||||
ReplyArea::ReplyArea(not_null<Controller*> controller)
|
||||
: _controller(controller)
|
||||
, _controls(std::make_unique<HistoryView::ComposeControls>(
|
||||
|
@ -599,10 +629,25 @@ void ReplyArea::show(ReplyAreaData data) {
|
|||
.history = history,
|
||||
});
|
||||
_controls->clear();
|
||||
if (!user || user->isSelf()) {
|
||||
_controls->hide();
|
||||
} else {
|
||||
const auto hidden = user && user->isSelf();
|
||||
const auto cant = !user || user->isServiceUser();
|
||||
if (!hidden && !cant) {
|
||||
_controls->show();
|
||||
} else {
|
||||
_controls->hide();
|
||||
if (cant) {
|
||||
_cant = std::make_unique<Cant>(_controller->wrap());
|
||||
_controller->layoutValue(
|
||||
) | rpl::start_with_next([=](const Layout &layout) {
|
||||
const auto height = st::storiesComposeControls.attach.height;
|
||||
const auto position = layout.controlsBottomPosition
|
||||
- QPoint(0, height);
|
||||
_cant->setGeometry(
|
||||
{ position, QSize{ layout.controlsWidth, height } });
|
||||
}, _cant->lifetime());
|
||||
} else {
|
||||
_cant = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ public:
|
|||
[[nodiscard]] rpl::producer<bool> hasSendTextValue() const;
|
||||
|
||||
private:
|
||||
class Cant;
|
||||
|
||||
using VoiceToSend = HistoryView::Controls::VoiceToSend;
|
||||
|
||||
[[nodiscard]] Main::Session &session() const;
|
||||
|
@ -134,6 +136,7 @@ private:
|
|||
|
||||
const not_null<Controller*> _controller;
|
||||
const std::unique_ptr<HistoryView::ComposeControls> _controls;
|
||||
std::unique_ptr<Cant> _cant;
|
||||
|
||||
ReplyAreaData _data;
|
||||
base::has_weak_ptr _shownUserGuard;
|
||||
|
|
Loading…
Add table
Reference in a new issue