mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 15:04:57 +00:00
Fixed wrong color index fallback when cloud peer color is missing.
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user