Show "Topic Author" fake admin rank.
This commit is contained in:
parent
aa5f9467f2
commit
af6ca8d4f1
|
@ -1682,6 +1682,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_admin_badge" = "admin";
|
"lng_admin_badge" = "admin";
|
||||||
"lng_owner_badge" = "owner";
|
"lng_owner_badge" = "owner";
|
||||||
"lng_channel_badge" = "channel";
|
"lng_channel_badge" = "channel";
|
||||||
|
"lng_topic_author_badge" = "Topic Author";
|
||||||
"lng_fast_reply" = "Reply";
|
"lng_fast_reply" = "Reply";
|
||||||
"lng_cancel_edit_post_sure" = "Cancel editing?";
|
"lng_cancel_edit_post_sure" = "Cancel editing?";
|
||||||
"lng_cancel_edit_post_yes" = "Yes";
|
"lng_cancel_edit_post_yes" = "Yes";
|
||||||
|
|
|
@ -149,6 +149,7 @@ ForumTopic::ForumTopic(not_null<Forum*> forum, MsgId rootId)
|
||||||
rootId))
|
rootId))
|
||||||
, _rootId(rootId)
|
, _rootId(rootId)
|
||||||
, _lastKnownServerMessageId(rootId)
|
, _lastKnownServerMessageId(rootId)
|
||||||
|
, _creatorId(creating() ? forum->session().userPeerId() : 0)
|
||||||
, _creationDate(creating() ? base::unixtime::now() : 0)
|
, _creationDate(creating() ? base::unixtime::now() : 0)
|
||||||
, _flags(creating() ? Flag::My : Flag()) {
|
, _flags(creating() ? Flag::My : Flag()) {
|
||||||
Thread::setMuted(owner().notifySettings().isMuted(this));
|
Thread::setMuted(owner().notifySettings().isMuted(this));
|
||||||
|
@ -203,6 +204,10 @@ MsgId ForumTopic::rootId() const {
|
||||||
return _rootId;
|
return _rootId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerId ForumTopic::creatorId() const {
|
||||||
|
return _creatorId;
|
||||||
|
}
|
||||||
|
|
||||||
TimeId ForumTopic::creationDate() const {
|
TimeId ForumTopic::creationDate() const {
|
||||||
return _creationDate;
|
return _creationDate;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +272,7 @@ void ForumTopic::readTillEnd() {
|
||||||
void ForumTopic::applyTopic(const MTPDforumTopic &data) {
|
void ForumTopic::applyTopic(const MTPDforumTopic &data) {
|
||||||
Expects(_rootId == data.vid().v);
|
Expects(_rootId == data.vid().v);
|
||||||
|
|
||||||
|
_creatorId = peerFromMTP(data.vfrom_id());
|
||||||
_creationDate = data.vdate().v;
|
_creationDate = data.vdate().v;
|
||||||
|
|
||||||
applyTitle(qs(data.vtitle()));
|
applyTitle(qs(data.vtitle()));
|
||||||
|
|
|
@ -60,6 +60,7 @@ public:
|
||||||
[[nodiscard]] not_null<Forum*> forum() const;
|
[[nodiscard]] not_null<Forum*> forum() const;
|
||||||
[[nodiscard]] rpl::producer<> destroyed() const;
|
[[nodiscard]] rpl::producer<> destroyed() const;
|
||||||
[[nodiscard]] MsgId rootId() const;
|
[[nodiscard]] MsgId rootId() const;
|
||||||
|
[[nodiscard]] PeerId creatorId() const;
|
||||||
[[nodiscard]] TimeId creationDate() const;
|
[[nodiscard]] TimeId creationDate() const;
|
||||||
|
|
||||||
[[nodiscard]] bool my() const;
|
[[nodiscard]] bool my() const;
|
||||||
|
@ -172,8 +173,9 @@ private:
|
||||||
DocumentId _iconId = 0;
|
DocumentId _iconId = 0;
|
||||||
base::flat_set<QString> _titleWords;
|
base::flat_set<QString> _titleWords;
|
||||||
base::flat_set<QChar> _titleFirstLetters;
|
base::flat_set<QChar> _titleFirstLetters;
|
||||||
int _titleVersion = 0;
|
PeerId _creatorId = 0;
|
||||||
TimeId _creationDate = 0;
|
TimeId _creationDate = 0;
|
||||||
|
int _titleVersion = 0;
|
||||||
int32 _colorId = 0;
|
int32 _colorId = 0;
|
||||||
Flags _flags;
|
Flags _flags;
|
||||||
|
|
||||||
|
|
|
@ -687,6 +687,10 @@ void InnerWidget::elementStartPremium(
|
||||||
void InnerWidget::elementCancelPremium(not_null<const Element*> view) {
|
void InnerWidget::elementCancelPremium(not_null<const Element*> view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString InnerWidget::elementAuthorRank(not_null<const Element*> view) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
void InnerWidget::saveState(not_null<SectionMemento*> memento) {
|
||||||
memento->setFilter(std::move(_filter));
|
memento->setFilter(std::move(_filter));
|
||||||
memento->setAdmins(std::move(_admins));
|
memento->setAdmins(std::move(_admins));
|
||||||
|
|
|
@ -143,6 +143,8 @@ public:
|
||||||
HistoryView::Element *replacing) override;
|
HistoryView::Element *replacing) override;
|
||||||
void elementCancelPremium(
|
void elementCancelPremium(
|
||||||
not_null<const HistoryView::Element*> view) override;
|
not_null<const HistoryView::Element*> view) override;
|
||||||
|
QString elementAuthorRank(
|
||||||
|
not_null<const HistoryView::Element*> view) override;
|
||||||
|
|
||||||
~InnerWidget();
|
~InnerWidget();
|
||||||
|
|
||||||
|
|
|
@ -275,6 +275,10 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString elementAuthorRank(not_null<const Element*> view) override {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
not_null<HistoryView::ElementDelegate*> delegate() override {
|
not_null<HistoryView::ElementDelegate*> delegate() override {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,6 +225,11 @@ void SimpleElementDelegate::elementCancelPremium(
|
||||||
not_null<const Element*> view) {
|
not_null<const Element*> view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SimpleElementDelegate::elementAuthorRank(
|
||||||
|
not_null<const Element*> view) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
TextSelection UnshiftItemSelection(
|
TextSelection UnshiftItemSelection(
|
||||||
TextSelection selection,
|
TextSelection selection,
|
||||||
uint16 byLength) {
|
uint16 byLength) {
|
||||||
|
|
|
@ -107,6 +107,7 @@ public:
|
||||||
not_null<const Element*> view,
|
not_null<const Element*> view,
|
||||||
Element *replacing) = 0;
|
Element *replacing) = 0;
|
||||||
virtual void elementCancelPremium(not_null<const Element*> view) = 0;
|
virtual void elementCancelPremium(not_null<const Element*> view) = 0;
|
||||||
|
virtual QString elementAuthorRank(not_null<const Element*> view) = 0;
|
||||||
|
|
||||||
virtual ~ElementDelegate() {
|
virtual ~ElementDelegate() {
|
||||||
}
|
}
|
||||||
|
@ -168,6 +169,8 @@ public:
|
||||||
not_null<const Element*> view,
|
not_null<const Element*> view,
|
||||||
Element *replacing) override;
|
Element *replacing) override;
|
||||||
void elementCancelPremium(not_null<const Element*> view) override;
|
void elementCancelPremium(not_null<const Element*> view) override;
|
||||||
|
QString elementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] not_null<Window::SessionController*> controller() const {
|
[[nodiscard]] not_null<Window::SessionController*> controller() const {
|
||||||
|
|
|
@ -1658,6 +1658,10 @@ void ListWidget::elementCancelPremium(not_null<const Element*> view) {
|
||||||
_emojiInteractions->cancelPremiumEffect(view);
|
_emojiInteractions->cancelPremiumEffect(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ListWidget::elementAuthorRank(not_null<const Element*> view) {
|
||||||
|
return _delegate->listElementAuthorRank(view);
|
||||||
|
}
|
||||||
|
|
||||||
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
void ListWidget::saveState(not_null<ListMemento*> memento) {
|
||||||
memento->setAroundPosition(_aroundPosition);
|
memento->setAroundPosition(_aroundPosition);
|
||||||
auto state = countScrollState();
|
auto state = countScrollState();
|
||||||
|
|
|
@ -139,6 +139,7 @@ public:
|
||||||
virtual void listPaintEmpty(
|
virtual void listPaintEmpty(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) = 0;
|
const Ui::ChatPaintContext &context) = 0;
|
||||||
|
virtual QString listElementAuthorRank(not_null<const Element*> view) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SelectionData {
|
struct SelectionData {
|
||||||
|
@ -319,6 +320,7 @@ public:
|
||||||
not_null<const Element*> view,
|
not_null<const Element*> view,
|
||||||
Element *replacing) override;
|
Element *replacing) override;
|
||||||
void elementCancelPremium(not_null<const Element*> view) override;
|
void elementCancelPremium(not_null<const Element*> view) override;
|
||||||
|
QString elementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
|
||||||
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
void setEmptyInfoWidget(base::unique_qptr<Ui::RpWidget> &&w);
|
||||||
|
|
||||||
|
|
|
@ -329,7 +329,10 @@ not_null<HistoryMessage*> Message::message() const {
|
||||||
|
|
||||||
void Message::refreshRightBadge() {
|
void Message::refreshRightBadge() {
|
||||||
const auto text = [&] {
|
const auto text = [&] {
|
||||||
if (data()->isDiscussionPost()) {
|
const auto author = delegate()->elementAuthorRank(this);
|
||||||
|
if (!author.isEmpty()) {
|
||||||
|
return author;
|
||||||
|
} else if (data()->isDiscussionPost()) {
|
||||||
return (delegate()->elementContext() == Context::Replies)
|
return (delegate()->elementContext() == Context::Replies)
|
||||||
? QString()
|
? QString()
|
||||||
: tr::lng_channel_badge(tr::now);
|
: tr::lng_channel_badge(tr::now);
|
||||||
|
@ -345,8 +348,8 @@ void Message::refreshRightBadge() {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
const auto info = channel->mgInfo.get();
|
const auto info = channel->mgInfo.get();
|
||||||
const auto i = channel->mgInfo->admins.find(peerToUser(user->id));
|
const auto i = info->admins.find(peerToUser(user->id));
|
||||||
const auto custom = (i != channel->mgInfo->admins.end())
|
const auto custom = (i != info->admins.end())
|
||||||
? i->second
|
? i->second
|
||||||
: (info->creator == user)
|
: (info->creator == user)
|
||||||
? info->creatorRank
|
? info->creatorRank
|
||||||
|
@ -355,7 +358,7 @@ void Message::refreshRightBadge() {
|
||||||
? custom
|
? custom
|
||||||
: (info->creator == user)
|
: (info->creator == user)
|
||||||
? tr::lng_owner_badge(tr::now)
|
? tr::lng_owner_badge(tr::now)
|
||||||
: (i != channel->mgInfo->admins.end())
|
: (i != info->admins.end())
|
||||||
? tr::lng_admin_badge(tr::now)
|
? tr::lng_admin_badge(tr::now)
|
||||||
: QString();
|
: QString();
|
||||||
}();
|
}();
|
||||||
|
|
|
@ -613,6 +613,10 @@ void PinnedWidget::listPaintEmpty(
|
||||||
const Ui::ChatPaintContext &context) {
|
const Ui::ChatPaintContext &context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PinnedWidget::listElementAuthorRank(not_null<const Element*> view) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void PinnedWidget::confirmDeleteSelected() {
|
void PinnedWidget::confirmDeleteSelected() {
|
||||||
ConfirmDeleteSelectedItems(_inner);
|
ConfirmDeleteSelectedItems(_inner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ public:
|
||||||
void listPaintEmpty(
|
void listPaintEmpty(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
|
|
@ -2453,6 +2453,12 @@ void RepliesWidget::listPaintEmpty(
|
||||||
_emptyPainter->paint(p, context.st, width(), _scroll->height());
|
_emptyPainter->paint(p, context.st, width(), _scroll->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RepliesWidget::listElementAuthorRank(not_null<const Element*> view) {
|
||||||
|
return (_topic && view->data()->from()->id == _topic->creatorId())
|
||||||
|
? tr::lng_topic_author_badge(tr::now)
|
||||||
|
: QString();
|
||||||
|
}
|
||||||
|
|
||||||
void RepliesWidget::setupEmptyPainter() {
|
void RepliesWidget::setupEmptyPainter() {
|
||||||
Expects(_topic != nullptr);
|
Expects(_topic != nullptr);
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ public:
|
||||||
void listPaintEmpty(
|
void listPaintEmpty(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
|
|
@ -1288,6 +1288,11 @@ void ScheduledWidget::listPaintEmpty(
|
||||||
const Ui::ChatPaintContext &context) {
|
const Ui::ChatPaintContext &context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ScheduledWidget::listElementAuthorRank(
|
||||||
|
not_null<const Element*> view) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void ScheduledWidget::confirmSendNowSelected() {
|
void ScheduledWidget::confirmSendNowSelected() {
|
||||||
ConfirmSendNowSelectedItems(_inner);
|
ConfirmSendNowSelectedItems(_inner);
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,7 @@ public:
|
||||||
void listPaintEmpty(
|
void listPaintEmpty(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::ChatPaintContext &context) override;
|
const Ui::ChatPaintContext &context) override;
|
||||||
|
QString listElementAuthorRank(not_null<const Element*> view) override;
|
||||||
|
|
||||||
// CornerButtonsDelegate delegate.
|
// CornerButtonsDelegate delegate.
|
||||||
void cornerButtonsShowAtPosition(
|
void cornerButtonsShowAtPosition(
|
||||||
|
|
Loading…
Reference in New Issue