| 543 | } |
| 544 | |
| 545 | void UserData::setFlags(UserDataFlags which) { |
| 546 | if (!isBot()) { |
| 547 | which &= ~Flag::Forum; |
| 548 | } |
| 549 | const auto diff = flags() ^ which; |
| 550 | if (diff & Flag::Deleted) { |
| 551 | invalidateEmptyUserpic(); |
| 552 | } |
| 553 | // Let Data::Forum live till the end of _flags.set. |
| 554 | // That way the data can be used in changes handler. |
| 555 | // Example: render frame for forum auto-closing animation. |
| 556 | const auto takenForum = (botInfo |
| 557 | && (diff & Flag::Forum) |
| 558 | && !(which & Flag::Forum)) |
| 559 | ? botInfo->takeForumData() |
| 560 | : nullptr; |
| 561 | if ((diff & Flag::Forum) && (which & Flag::Forum)) { |
| 562 | if (const auto info = botInfo.get()) { |
| 563 | info->ensureForum(this); |
| 564 | } |
| 565 | } |
| 566 | _flags.set((flags() & Flag::Self) | (which & ~Flag::Self)); |
| 567 | if (diff & Flag::Forum) { |
| 568 | if (const auto history = this->owner().historyLoaded(this)) { |
| 569 | if (diff & Flag::Forum) { |
| 570 | Core::App().notifications().clearFromHistory(history); |
| 571 | history->updateChatListEntryHeight(); |
| 572 | if (history->inChatList()) { |
| 573 | if (const auto forum = this->forum()) { |
| 574 | forum->preloadTopics(); |
| 575 | } |
| 576 | } |
| 577 | } |
| 578 | } |
| 579 | } |
| 580 | if (const auto raw = takenForum.get()) { |
| 581 | owner().forumIcons().clearUserpicsReset(raw); |
| 582 | } |
| 583 | } |
| 584 | |
| 585 | void UserData::addFlags(UserDataFlags which) { |
| 586 | setFlags(flags() | which); |
no test coverage detected