Replaced observable updatedNotifier() with rpl.

This commit is contained in:
23rd 2019-05-11 13:46:04 +03:00 committed by John Preston
parent 26be382b02
commit b4df7b4efd
6 changed files with 22 additions and 16 deletions

View File

@ -386,9 +386,12 @@ MainWidget::MainWidget(
connect(_dialogs, SIGNAL(cancelled()), this, SLOT(dialogsCancelled()));
connect(this, SIGNAL(dialogsUpdated()), _dialogs, SLOT(onListScroll()));
connect(_history, &HistoryWidget::cancelled, [=] { handleHistoryBack(); });
subscribe(
Media::Player::instance()->updatedNotifier(),
[=](const Media::Player::TrackState &state) { handleAudioUpdate(state); });
Media::Player::instance()->updatedNotifier(
) | rpl::start_with_next([=](const Media::Player::TrackState &state) {
handleAudioUpdate(state);
}, lifetime());
subscribe(session().calls().currentCallChanged(), [this](Calls::Call *call) { setCurrentCall(call); });
session().data().currentExportView(

View File

@ -614,7 +614,7 @@ void Instance::emitUpdate(AudioMsgId::Type type, CheckCallback check) {
if (data->streamed && !data->streamed->info.video.size.isEmpty()) {
data->streamed->progress.updateState(state);
}
_updatedNotifier.notify(state, true);
_updatedNotifier.fire_copy({state});
if (data->isPlaying && state.state == State::StoppedAtEnd) {
if (data->repeatEnabled) {
play(data->current);

View File

@ -131,9 +131,6 @@ public:
base::Observable<bool> &playerWidgetOver() {
return _playerWidgetOver;
}
base::Observable<TrackState> &updatedNotifier() {
return _updatedNotifier;
}
base::Observable<AudioMsgId::Type> &tracksFinishedNotifier() {
return _tracksFinishedNotifier;
}
@ -152,6 +149,9 @@ public:
rpl::producer<bool> playerWidgetToggled() const {
return _playerWidgetToggled.events();
}
rpl::producer<TrackState> updatedNotifier() const {
return _updatedNotifier.events();
}
void documentLoadProgress(DocumentData *document);
@ -254,12 +254,12 @@ private:
base::Observable<Switch> _switchToNextNotifier;
base::Observable<bool> _playerWidgetOver;
base::Observable<TrackState> _updatedNotifier;
base::Observable<AudioMsgId::Type> _tracksFinishedNotifier;
base::Observable<AudioMsgId::Type> _trackChangedNotifier;
base::Observable<AudioMsgId::Type> _repeatChangedNotifier;
rpl::event_stream<bool> _playerWidgetToggled;
rpl::event_stream<TrackState> _updatedNotifier;
rpl::lifetime _lifetime;
};

View File

@ -147,9 +147,6 @@ Widget::Widget(QWidget *parent) : RpWidget(parent)
updateRepeatTrackIcon();
}
});
subscribe(instance()->updatedNotifier(), [this](const TrackState &state) {
handleSongUpdate(state);
});
subscribe(instance()->trackChangedNotifier(), [this](AudioMsgId::Type type) {
if (type == _type) {
handleSongChange();
@ -165,6 +162,12 @@ Widget::Widget(QWidget *parent) : RpWidget(parent)
}
}
});
instance()->updatedNotifier(
) | rpl::start_with_next([=](const TrackState &state) {
handleSongUpdate(state);
}, lifetime());
setType(AudioMsgId::Type::Song);
_playPause->finishTransform();
}

View File

@ -413,11 +413,6 @@ MainWindow::MainWindow()
_private->_touchBar = nullptr;
}
});
subscribe(Media::Player::instance()->updatedNotifier(),
[=](const Media::Player::TrackState &state) {
[_private->_touchBar handleTrackStateChange:state];
});
}
void MainWindow::closeWithoutDestroy() {

View File

@ -283,6 +283,11 @@ NSString* FormatTime(int time) {
[self setTouchBar:TouchBarType::AudioPlayer];
}
}, self->lifetime);
Media::Player::instance()->updatedNotifier(
) | rpl::start_with_next([=](const Media::Player::TrackState &state) {
[self handleTrackStateChange:state];
}, self->lifetime);
Core::App().passcodeLockChanges(
) | rpl::start_with_next([=](bool locked) {