| 1725 | } |
| 1726 | |
| 1727 | void Session::setupUserIsContactViewer() { |
| 1728 | session().changes().peerUpdates( |
| 1729 | PeerUpdate::Flag::IsContact |
| 1730 | ) | rpl::map([](const PeerUpdate &update) { |
| 1731 | return update.peer->asUser(); |
| 1732 | }) | rpl::on_next([=](not_null<UserData*> user) { |
| 1733 | const auto i = _contactViews.find(peerToUser(user->id)); |
| 1734 | if (i != _contactViews.end()) { |
| 1735 | for (const auto &view : i->second) { |
| 1736 | requestViewResize(view); |
| 1737 | } |
| 1738 | } |
| 1739 | if (!user->isLoaded()) { |
| 1740 | LOG(("API Error: " |
| 1741 | "userIsContactChanged() called for a not loaded user!")); |
| 1742 | return; |
| 1743 | } |
| 1744 | if (user->isContact()) { |
| 1745 | const auto history = this->history(user->id); |
| 1746 | _contactsList.addByName(history); |
| 1747 | if (!history->inChatList()) { |
| 1748 | _contactsNoChatsList.addByName(history); |
| 1749 | } |
| 1750 | } else if (const auto history = historyLoaded(user)) { |
| 1751 | _contactsNoChatsList.remove(history); |
| 1752 | _contactsList.remove(history); |
| 1753 | } |
| 1754 | }, _lifetime); |
| 1755 | } |
| 1756 | |
| 1757 | Session::~Session() = default; |
| 1758 |
nothing calls this directly
no test coverage detected