2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 23:55:12 +00:00

Update API scheme on layer 166.

This commit is contained in:
John Preston
2023-10-18 11:29:42 +04:00
parent 12fab565a4
commit 16d18b437d
7 changed files with 149 additions and 86 deletions

View File

@@ -158,7 +158,8 @@ void PeerClickHandler::onClick(ClickContext context) const {
PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
: id(id)
, _owner(owner) {
, _owner(owner)
, _colorIndex(Data::DecideColorIndex(id)) {
}
Data::Session &PeerData::owner() const {
@@ -619,6 +620,13 @@ void PeerData::setSettings(const MTPPeerSettings &data) {
});
}
bool PeerData::changeColorIndex(
const tl::conditional<MTPint> &cloudColorIndex) {
return cloudColorIndex
? changeColorIndex(cloudColorIndex->v)
: clearColorIndex();
}
void PeerData::fillNames() {
_nameWords.clear();
_nameFirstLetters.clear();
@@ -837,13 +845,23 @@ QString PeerData::userName() const {
bool PeerData::changeColorIndex(uint8 index) {
index %= Ui::kColorIndexCount;
if (_colorIndex == index) {
if (_colorIndexCloud && _colorIndex == index) {
return false;
}
_colorIndexCloud = true;
_colorIndex = index;
return true;
}
bool PeerData::clearColorIndex() {
if (!_colorIndexCloud) {
return false;
}
_colorIndexCloud = false;
_colorIndex = Data::DecideColorIndex(id);
return true;
}
bool PeerData::isSelf() const {
if (const auto user = asUser()) {
return (user->flags() & UserDataFlag::Self);