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