2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Channels list in feed info with leave channel.

This commit is contained in:
John Preston
2018-02-08 12:20:14 +03:00
parent f23c23f696
commit 906cb95e67
17 changed files with 259 additions and 89 deletions

View File

@@ -60,6 +60,11 @@ void UpdateImage(ImagePtr &old, ImagePtr now) {
Session::Session(not_null<AuthSession*> session)
: _session(session)
, _groups(this) {
setupContactViewsViewer();
setupChannelLeavingViewer();
}
void Session::setupContactViewsViewer() {
Notify::PeerUpdateViewer(
Notify::PeerUpdate::Flag::UserIsContact
) | rpl::map([](const Notify::PeerUpdate &update) {
@@ -71,6 +76,20 @@ Session::Session(not_null<AuthSession*> session)
}, _lifetime);
}
void Session::setupChannelLeavingViewer() {
Notify::PeerUpdateViewer(
Notify::PeerUpdate::Flag::ChannelAmIn
) | rpl::map([](const Notify::PeerUpdate &update) {
return update.peer->asChannel();
}) | rpl::filter([](ChannelData *channel) {
return (channel != nullptr)
&& !(channel->amIn())
&& (channel->feed() != nullptr);
}) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
channel->clearFeed();
}, _lifetime);
}
Session::~Session() = default;
template <typename Method>
@@ -1447,6 +1466,18 @@ Feed *Session::feedLoaded(FeedId id) {
return (it == end(_feeds)) ? nullptr : it->second.get();
}
void Session::setDefaultFeedId(FeedId id) {
_defaultFeedId = id;
}
FeedId Session::defaultFeedId() const {
return _defaultFeedId.current();
}
rpl::producer<FeedId> Session::defaultFeedIdValue() const {
return _defaultFeedId.value();
}
void Session::forgetMedia() {
for (const auto &[id, photo] : _photos) {
photo->forget();