mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Replaced observable in SessionController with rpl.
This commit is contained in:
parent
a164cb9480
commit
386fae952b
7 changed files with 25 additions and 21 deletions
|
@ -188,12 +188,13 @@ GifsListWidget::GifsListWidget(
|
|||
update();
|
||||
}, lifetime());
|
||||
|
||||
subscribe(controller->gifPauseLevelChanged(), [=] {
|
||||
controller->gifPauseLevelChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (!controller->isGifPausedAtLeastFor(
|
||||
Window::GifPauseReason::SavedGifs)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
rpl::producer<TabbedSelector::FileChosen> GifsListWidget::fileChosen() const {
|
||||
|
|
|
@ -46,8 +46,7 @@ void AddGifAction(
|
|||
|
||||
class GifsListWidget
|
||||
: public TabbedSelector::Inner
|
||||
, public InlineBots::Layout::Context
|
||||
, private base::Subscriber {
|
||||
, public InlineBots::Layout::Context {
|
||||
public:
|
||||
using InlineChosen = TabbedSelector::InlineChosen;
|
||||
|
||||
|
|
|
@ -169,11 +169,13 @@ HistoryInner::HistoryInner(
|
|||
notifyIsBotChanged();
|
||||
|
||||
setMouseTracking(true);
|
||||
subscribe(_controller->gifPauseLevelChanged(), [this] {
|
||||
if (!_controller->isGifPausedAtLeastFor(Window::GifPauseReason::Any)) {
|
||||
_controller->gifPauseLevelChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (!_controller->isGifPausedAtLeastFor(
|
||||
Window::GifPauseReason::Any)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
subscribe(_controller->widget()->dragFinished(), [this] {
|
||||
mouseActionUpdate(QCursor::pos());
|
||||
});
|
||||
|
|
|
@ -48,11 +48,13 @@ Inner::Inner(
|
|||
update();
|
||||
}, lifetime());
|
||||
|
||||
subscribe(controller->gifPauseLevelChanged(), [this] {
|
||||
if (!_controller->isGifPausedAtLeastFor(Window::GifPauseReason::InlineResults)) {
|
||||
controller->gifPauseLevelChanged(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (!_controller->isGifPausedAtLeastFor(
|
||||
Window::GifPauseReason::InlineResults)) {
|
||||
update();
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
_controller->session().changes().peerUpdates(
|
||||
Data::PeerUpdate::Flag::Rights
|
||||
|
|
|
@ -61,8 +61,7 @@ struct CacheEntry {
|
|||
class Inner
|
||||
: public Ui::RpWidget
|
||||
, public Ui::AbstractTooltipShower
|
||||
, public Context
|
||||
, private base::Subscriber {
|
||||
, public Context {
|
||||
|
||||
public:
|
||||
Inner(QWidget *parent, not_null<Window::SessionController*> controller);
|
||||
|
|
|
@ -465,12 +465,14 @@ SessionController::SessionController(
|
|||
enableGifPauseReason(GifPauseReason::RoundPlaying);
|
||||
}
|
||||
|
||||
subscribe(session->api().fullPeerUpdated(), [=](PeerData *peer) {
|
||||
base::ObservableViewer(
|
||||
session->api().fullPeerUpdated()
|
||||
) | rpl::start_with_next([=](PeerData *peer) {
|
||||
if (peer == _showEditPeer) {
|
||||
_showEditPeer = nullptr;
|
||||
Ui::show(Box<EditPeerInfoBox>(this, peer));
|
||||
}
|
||||
});
|
||||
}, lifetime());
|
||||
|
||||
session->data().chatsListChanges(
|
||||
) | rpl::filter([=](Data::Folder *folder) {
|
||||
|
@ -753,7 +755,7 @@ void SessionController::enableGifPauseReason(GifPauseReason reason) {
|
|||
auto notify = (static_cast<int>(_gifPauseReasons) < static_cast<int>(reason));
|
||||
_gifPauseReasons |= reason;
|
||||
if (notify) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
_gifPauseLevelChanged.fire({});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -762,7 +764,7 @@ void SessionController::disableGifPauseReason(GifPauseReason reason) {
|
|||
if (_gifPauseReasons & reason) {
|
||||
_gifPauseReasons &= ~reason;
|
||||
if (_gifPauseReasons < reason) {
|
||||
_gifPauseLevelChanged.notify();
|
||||
_gifPauseLevelChanged.fire({});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include <rpl/variable.h>
|
||||
#include "base/flags.h"
|
||||
#include "base/observer.h"
|
||||
#include "base/object_ptr.h"
|
||||
#include "base/weak_ptr.h"
|
||||
#include "base/timer.h"
|
||||
|
@ -227,7 +226,7 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class SessionController : public SessionNavigation, private base::Subscriber {
|
||||
class SessionController : public SessionNavigation {
|
||||
public:
|
||||
SessionController(
|
||||
not_null<Main::Session*> session,
|
||||
|
@ -275,8 +274,8 @@ public:
|
|||
|
||||
void enableGifPauseReason(GifPauseReason reason);
|
||||
void disableGifPauseReason(GifPauseReason reason);
|
||||
base::Observable<void> &gifPauseLevelChanged() {
|
||||
return _gifPauseLevelChanged;
|
||||
rpl::producer<> gifPauseLevelChanged() const {
|
||||
return _gifPauseLevelChanged.events();
|
||||
}
|
||||
bool isGifPausedAtLeastFor(GifPauseReason reason) const;
|
||||
void floatPlayerAreaUpdated();
|
||||
|
@ -406,7 +405,7 @@ private:
|
|||
std::unique_ptr<FiltersMenu> _filters;
|
||||
|
||||
GifPauseReasons _gifPauseReasons = 0;
|
||||
base::Observable<void> _gifPauseLevelChanged;
|
||||
rpl::event_stream<> _gifPauseLevelChanged;
|
||||
|
||||
// Depends on _gifPause*.
|
||||
const std::unique_ptr<ChatHelpers::TabbedSelector> _tabbedSelector;
|
||||
|
|
Loading…
Add table
Reference in a new issue