Fix mediaview update when image is loaded.

Subscribe on app launch, not only when AuthSession has changed.
This commit is contained in:
John Preston 2017-03-10 11:25:38 +03:00
parent ee45bbe4c6
commit e4f7b3c7c2
1 changed files with 13 additions and 8 deletions

View File

@ -90,15 +90,20 @@ MediaView::MediaView(QWidget*) : TWidget(nullptr)
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int)));
// While we have one mediaview for all authsessions we have to do this.
subscribe(Messenger::Instance().authSessionChanged(), [this] {
if (!AuthSession::Exists()) return;
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
if (!isHidden()) {
updateControls();
}
});
auto subscribeToDownloadFinished = [this] {
if (AuthSession::Exists()) {
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
if (!isHidden()) {
updateControls();
}
});
}
};
subscribe(Messenger::Instance().authSessionChanged(), [this, subscribeToDownloadFinished] {
subscribeToDownloadFinished();
});
subscribeToDownloadFinished();
auto observeEvents = Notify::PeerUpdate::Flag::SharedMediaChanged;
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(observeEvents, [this](const Notify::PeerUpdate &update) {
mediaOverviewUpdated(update);