Removed unused code of hidden sender userpics for sponsored messages.

This commit is contained in:
23rd 2023-11-15 18:55:56 +03:00 committed by John Preston
parent fc86bb7a5f
commit 3f19dc0486
6 changed files with 1 additions and 115 deletions

View file

@ -326,13 +326,6 @@ void PaintRow(
context.st->padding.top(), context.st->padding.top(),
context.width, context.width,
context.st->photoSize); context.st->photoSize);
} else if (!from && hiddenSenderInfo) {
hiddenSenderInfo->emptyUserpic.paintCircle(
p,
context.st->padding.left(),
context.st->padding.top(),
context.width,
context.st->photoSize);
} else if (!(flags & Flag::AllowUserOnline)) { } else if (!(flags & Flag::AllowUserOnline)) {
PaintUserpic( PaintUserpic(
p, p,

View file

@ -1273,27 +1273,6 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
width(), width(),
st::msgPhotoSize, st::msgPhotoSize,
context.paused); context.paused);
} else if (const auto info = item->hiddenSenderInfo()) {
if (info->customUserpic.empty()) {
info->emptyUserpic.paintCircle(
p,
st::historyPhotoLeft,
userpicTop,
width(),
st::msgPhotoSize);
} else {
auto &userpic = _hiddenSenderUserpics[item->id];
const auto valid = info->paintCustomUserpic(
p,
userpic,
st::historyPhotoLeft,
userpicTop,
width(),
st::msgPhotoSize);
if (!valid) {
info->customUserpic.load(&session(), item->fullId());
}
}
} else { } else {
Unexpected("Corrupt forwarded information in message."); Unexpected("Corrupt forwarded information in message.");
} }

View file

@ -116,12 +116,7 @@ HiddenSenderInfo::HiddenSenderInfo(
std::optional<uint8> colorIndex) std::optional<uint8> colorIndex)
: name(name) : name(name)
, colorIndex(colorIndex.value_or( , colorIndex(colorIndex.value_or(
Data::DecideColorIndex(Data::FakePeerIdForJustName(name)))) Data::DecideColorIndex(Data::FakePeerIdForJustName(name)))) {
, emptyUserpic(
Ui::EmptyUserpic::UserpicColor(this->colorIndex),
(external
? Ui::EmptyUserpic::ExternalName()
: name)) {
Expects(!name.isEmpty()); Expects(!name.isEmpty());
const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts); const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts);
@ -153,35 +148,6 @@ ClickHandlerPtr HiddenSenderInfo::ForwardClickHandler() {
return hidden; return hidden;
} }
bool HiddenSenderInfo::paintCustomUserpic(
Painter &p,
Ui::PeerUserpicView &view,
int x,
int y,
int outerWidth,
int size) const {
Expects(!customUserpic.empty());
auto valid = true;
if (!customUserpic.isCurrentView(view.cloud)) {
view.cloud = customUserpic.createView();
valid = false;
}
const auto image = *view.cloud;
if (image.isNull()) {
emptyUserpic.paintCircle(p, x, y, outerWidth, size);
return valid;
}
Ui::ValidateUserpicCache(
view,
image.isNull() ? nullptr : &image,
image.isNull() ? &emptyUserpic : nullptr,
size * style::DevicePixelRatio(),
false);
p.drawImage(QRect(x, y, size, size), view.cached);
return valid;
}
void HistoryMessageForwarded::create(const HistoryMessageVia *via) const { void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
auto phrase = TextWithEntities(); auto phrase = TextWithEntities();
const auto fromChannel = originalSender const auto fromChannel = originalSender

View file

@ -97,19 +97,10 @@ public:
QString firstName; QString firstName;
QString lastName; QString lastName;
uint8 colorIndex = 0; uint8 colorIndex = 0;
Ui::EmptyUserpic emptyUserpic;
mutable Data::CloudImage customUserpic;
[[nodiscard]] static ClickHandlerPtr ForwardClickHandler(); [[nodiscard]] static ClickHandlerPtr ForwardClickHandler();
[[nodiscard]] const Ui::Text::String &nameText() const; [[nodiscard]] const Ui::Text::String &nameText() const;
[[nodiscard]] bool paintCustomUserpic(
Painter &p,
Ui::PeerUserpicView &view,
int x,
int y,
int outerWidth,
int size) const;
inline bool operator==(const HiddenSenderInfo &other) const { inline bool operator==(const HiddenSenderInfo &other) const {
return name == other.name; return name == other.name;

View file

@ -376,28 +376,6 @@ void PreviewWrap::paintEvent(QPaintEvent *e) {
userpicTop, userpicTop,
width(), width(),
st::msgPhotoSize); st::msgPhotoSize);
} else if (const auto info = item->hiddenSenderInfo()) {
if (info->customUserpic.empty()) {
info->emptyUserpic.paintCircle(
p,
st::historyPhotoLeft,
userpicTop,
width(),
st::msgPhotoSize);
} else {
const auto valid = info->paintCustomUserpic(
p,
_userpic,
st::historyPhotoLeft,
userpicTop,
width(),
st::msgPhotoSize);
if (!valid) {
info->customUserpic.load(
&item->history()->session(),
item->fullId());
}
}
} else { } else {
Unexpected("Corrupt forwarded information in message."); Unexpected("Corrupt forwarded information in message.");
} }

View file

@ -2181,27 +2181,6 @@ void ListWidget::paintEvent(QPaintEvent *e) {
userpicTop, userpicTop,
view->width(), view->width(),
st::msgPhotoSize); st::msgPhotoSize);
} else if (const auto info = item->hiddenSenderInfo()) {
if (info->customUserpic.empty()) {
info->emptyUserpic.paintCircle(
p,
st::historyPhotoLeft,
userpicTop,
view->width(),
st::msgPhotoSize);
} else {
auto &userpic = _hiddenSenderUserpics[item->id];
const auto valid = info->paintCustomUserpic(
p,
userpic,
st::historyPhotoLeft,
userpicTop,
view->width(),
st::msgPhotoSize);
if (!valid) {
info->customUserpic.load(session, item->fullId());
}
}
} else { } else {
Unexpected("Corrupt forwarded information in message."); Unexpected("Corrupt forwarded information in message.");
} }