Fixed wrong color index fallback when cloud peer color is missing.

This commit is contained in:
23rd
2026-01-30 10:50:23 +03:00
parent 527e742a89
commit fa785b745b
3 changed files with 14 additions and 14 deletions
+12 -12
View File
@@ -1055,8 +1055,9 @@ bool PeerData::changeColorCollectible(
bool PeerData::changeColor(
const tl::conditional<MTPPeerColor> &cloudColor) {
const auto changed1 = cloudColor
? changeColorIndex(Data::ColorIndexFromColor(cloudColor))
const auto maybeColorIndex = Data::ColorIndexFromColor(cloudColor);
const auto changed1 = maybeColorIndex
? changeColorIndex(*maybeColorIndex)
: clearColorIndex();
const auto changed2 = changeBackgroundEmojiId(
Data::BackgroundEmojiIdFromColor(cloudColor));
@@ -1066,8 +1067,9 @@ bool PeerData::changeColor(
bool PeerData::changeColorProfile(
const tl::conditional<MTPPeerColor> &cloudColor) {
const auto changed1 = cloudColor
? changeColorProfileIndex(Data::ColorIndexFromColor(cloudColor))
const auto maybeColorIndex = Data::ColorIndexFromColor(cloudColor);
const auto changed1 = maybeColorIndex
? changeColorProfileIndex(*maybeColorIndex)
: clearColorProfileIndex();
const auto changed2 = changeProfileBackgroundEmojiId(
Data::BackgroundEmojiIdFromColor(cloudColor));
@@ -2207,16 +2209,14 @@ uint64 BackgroundEmojiIdFromColor(const MTPPeerColor *color) {
});
}
uint8 ColorIndexFromColor(const MTPPeerColor *color) {
std::optional<uint8> ColorIndexFromColor(const MTPPeerColor *color) {
if (!color) {
return 0;
return std::nullopt;
}
return color->match([](const MTPDpeerColor &data) -> uint8 {
return data.vcolor().value_or_empty();
}, [](const MTPDpeerColorCollectible &data) -> uint8 {
return 0;
}, [](const MTPDinputPeerColorCollectible &) -> uint8 {
return 0;
return color->match([](const MTPDpeerColor &d) -> std::optional<uint8> {
return d.vcolor() ? std::make_optional(d.vcolor()->v) : std::nullopt;
}, [](const auto &) -> std::optional<uint8> {
return std::nullopt;
});
}