Skip to content

Commit

Permalink
Improve compile time.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 21, 2017
1 parent 6ca105a commit d93c1cc
Show file tree
Hide file tree
Showing 69 changed files with 693 additions and 5,023 deletions.
132 changes: 132 additions & 0 deletions Telegram/SourceFiles/auth_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,88 @@ void AuthSessionData::constructFromSerialized(const QByteArray &serialized) {
}
}

void AuthSessionData::markItemLayoutChanged(not_null<const HistoryItem*> item) {
_itemLayoutChanged.fire_copy(item);
}

rpl::producer<not_null<const HistoryItem*>> AuthSessionData::itemLayoutChanged() const {
return _itemLayoutChanged.events();
}

void AuthSessionData::requestItemRepaint(not_null<const HistoryItem*> item) {
_itemRepaintRequest.fire_copy(item);
}

rpl::producer<not_null<const HistoryItem*>> AuthSessionData::itemRepaintRequest() const {
return _itemRepaintRequest.events();
}

void AuthSessionData::markItemRemoved(not_null<const HistoryItem*> item) {
_itemRemoved.fire_copy(item);
}

rpl::producer<not_null<const HistoryItem*>> AuthSessionData::itemRemoved() const {
return _itemRemoved.events();
}

void AuthSessionData::markHistoryUnloaded(not_null<const History*> history) {
_historyUnloaded.fire_copy(history);
}

rpl::producer<not_null<const History*>> AuthSessionData::historyUnloaded() const {
return _historyUnloaded.events();
}

void AuthSessionData::markHistoryCleared(not_null<const History*> history) {
_historyCleared.fire_copy(history);
}

rpl::producer<not_null<const History*>> AuthSessionData::historyCleared() const {
return _historyCleared.events();
}

void AuthSessionData::removeMegagroupParticipant(
not_null<ChannelData*> channel,
not_null<UserData*> user) {
_megagroupParticipantRemoved.fire({ channel, user });
}

auto AuthSessionData::megagroupParticipantRemoved() const -> rpl::producer<MegagroupParticipant> {
return _megagroupParticipantRemoved.events();
}

rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantRemoved(
not_null<ChannelData*> channel) const {
return megagroupParticipantRemoved()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
}

void AuthSessionData::addNewMegagroupParticipant(
not_null<ChannelData*> channel,
not_null<UserData*> user) {
_megagroupParticipantAdded.fire({ channel, user });
}

auto AuthSessionData::megagroupParticipantAdded() const -> rpl::producer<MegagroupParticipant> {
return _megagroupParticipantAdded.events();
}

rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantAdded(
not_null<ChannelData*> channel) const {
return megagroupParticipantAdded()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
}

void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) {
_variables.tabbedSelectorSectionEnabled = enabled;
if (enabled) {
Expand All @@ -198,6 +280,11 @@ void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) {
setTabbedReplacedWithInfo(false);
}

rpl::producer<bool> AuthSessionData::tabbedReplacedWithInfoValue() const {
return _tabbedReplacedWithInfoValue.events_starting_with(
tabbedReplacedWithInfo());
}

void AuthSessionData::setThirdSectionInfoEnabled(bool enabled) {
if (_variables.thirdSectionInfoEnabled != enabled) {
_variables.thirdSectionInfoEnabled = enabled;
Expand All @@ -209,6 +296,11 @@ void AuthSessionData::setThirdSectionInfoEnabled(bool enabled) {
}
}

rpl::producer<bool> AuthSessionData::thirdSectionInfoEnabledValue() const {
return _thirdSectionInfoEnabledValue.events_starting_with(
thirdSectionInfoEnabled());
}

void AuthSessionData::setTabbedReplacedWithInfo(bool enabled) {
if (_tabbedReplacedWithInfo != enabled) {
_tabbedReplacedWithInfo = enabled;
Expand All @@ -224,6 +316,46 @@ QString AuthSessionData::getSoundPath(const QString &key) const {
return qsl(":/sounds/") + key + qsl(".mp3");
}

void AuthSessionData::setDialogsWidthRatio(float64 ratio) {
_variables.dialogsWidthRatio = ratio;
}

float64 AuthSessionData::dialogsWidthRatio() const {
return _variables.dialogsWidthRatio.current();
}

rpl::producer<float64> AuthSessionData::dialogsWidthRatioChanges() const {
return _variables.dialogsWidthRatio.changes();
}

void AuthSessionData::setThirdColumnWidth(int width) {
_variables.thirdColumnWidth = width;
}

int AuthSessionData::thirdColumnWidth() const {
return _variables.thirdColumnWidth.current();
}

rpl::producer<int> AuthSessionData::thirdColumnWidthChanges() const {
return _variables.thirdColumnWidth.changes();
}

void AuthSessionData::markStickersUpdated() {
_stickersUpdated.fire({});
}

rpl::producer<> AuthSessionData::stickersUpdated() const {
return _stickersUpdated.events();
}

void AuthSessionData::markSavedGifsUpdated() {
_savedGifsUpdated.fire({});
}

rpl::producer<> AuthSessionData::savedGifsUpdated() const {
return _savedGifsUpdated.events();
}

AuthSession &Auth() {
auto result = Messenger::Instance().authSession();
Assert(result != nullptr);
Expand Down
136 changes: 33 additions & 103 deletions Telegram/SourceFiles/auth_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,75 +70,31 @@ class AuthSessionData final {
base::Observable<ItemVisibilityQuery> &queryItemVisibility() {
return _queryItemVisibility;
}
void markItemLayoutChanged(not_null<const HistoryItem*> item) {
_itemLayoutChanged.fire_copy(item);
}
rpl::producer<not_null<const HistoryItem*>> itemLayoutChanged() const {
return _itemLayoutChanged.events();
}
void requestItemRepaint(not_null<const HistoryItem*> item) {
_itemRepaintRequest.fire_copy(item);
}
rpl::producer<not_null<const HistoryItem*>> itemRepaintRequest() const {
return _itemRepaintRequest.events();
}
void markItemRemoved(not_null<const HistoryItem*> item) {
_itemRemoved.fire_copy(item);
}
rpl::producer<not_null<const HistoryItem*>> itemRemoved() const {
return _itemRemoved.events();
}
void markHistoryUnloaded(not_null<const History*> history) {
_historyUnloaded.fire_copy(history);
}
rpl::producer<not_null<const History*>> historyUnloaded() const {
return _historyUnloaded.events();
}
void markHistoryCleared(not_null<const History*> history) {
_historyCleared.fire_copy(history);
}
rpl::producer<not_null<const History*>> historyCleared() const {
return _historyCleared.events();
}
void markItemLayoutChanged(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemLayoutChanged() const;
void requestItemRepaint(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemRepaintRequest() const;
void markItemRemoved(not_null<const HistoryItem*> item);
rpl::producer<not_null<const HistoryItem*>> itemRemoved() const;
void markHistoryUnloaded(not_null<const History*> history);
rpl::producer<not_null<const History*>> historyUnloaded() const;
void markHistoryCleared(not_null<const History*> history);
rpl::producer<not_null<const History*>> historyCleared() const;
using MegagroupParticipant = std::tuple<
not_null<ChannelData*>,
not_null<UserData*>>;
void removeMegagroupParticipant(
not_null<ChannelData*> channel,
not_null<UserData*> user) {
_megagroupParticipantRemoved.fire({ channel, user });
}
auto megagroupParticipantRemoved() const {
return _megagroupParticipantRemoved.events();
}
auto megagroupParticipantRemoved(
not_null<ChannelData*> channel) const {
return megagroupParticipantRemoved()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
}
not_null<ChannelData*> channel,
not_null<UserData*> user);
rpl::producer<MegagroupParticipant> megagroupParticipantRemoved() const;
rpl::producer<not_null<UserData*>> megagroupParticipantRemoved(
not_null<ChannelData*> channel) const;
void addNewMegagroupParticipant(
not_null<ChannelData*> channel,
not_null<UserData*> user) {
_megagroupParticipantAdded.fire({ channel, user });
}
auto megagroupParticipantAdded() const {
return _megagroupParticipantAdded.events();
}
auto megagroupParticipantAdded(
not_null<ChannelData*> channel) const {
return megagroupParticipantAdded()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
}
not_null<ChannelData*> channel,
not_null<UserData*> user);
rpl::producer<MegagroupParticipant> megagroupParticipantAdded() const;
rpl::producer<not_null<UserData*>> megagroupParticipantAdded(
not_null<ChannelData*> channel) const;

void moveFrom(AuthSessionData &&other) {
_variables = std::move(other._variables);
Expand Down Expand Up @@ -166,10 +122,7 @@ class AuthSessionData final {
return _variables.thirdSectionInfoEnabled;
}
void setThirdSectionInfoEnabled(bool enabled);
auto thirdSectionInfoEnabledValue() const {
return _thirdSectionInfoEnabledValue.events_starting_with(
thirdSectionInfoEnabled());
}
rpl::producer<bool> thirdSectionInfoEnabledValue() const;
int thirdSectionExtendedBy() const {
return _variables.thirdSectionExtendedBy;
}
Expand All @@ -180,10 +133,7 @@ class AuthSessionData final {
return _tabbedReplacedWithInfo;
}
void setTabbedReplacedWithInfo(bool enabled);
auto tabbedReplacedWithInfoValue() const {
return _tabbedReplacedWithInfoValue.events_starting_with(
tabbedReplacedWithInfo());
}
rpl::producer<bool> tabbedReplacedWithInfoValue() const;
void setSmallDialogsList(bool enabled) {
_variables.smallDialogsList = enabled;
}
Expand Down Expand Up @@ -221,37 +171,17 @@ class AuthSessionData final {
RectPart floatPlayerCorner() const {
return _variables.floatPlayerCorner;
}
void setDialogsWidthRatio(float64 ratio) {
_variables.dialogsWidthRatio = ratio;
}
float64 dialogsWidthRatio() const {
return _variables.dialogsWidthRatio.current();
}
rpl::producer<float64> dialogsWidthRatioChanges() const {
return _variables.dialogsWidthRatio.changes();
}
void setThirdColumnWidth(int width) {
_variables.thirdColumnWidth = width;
}
int thirdColumnWidth() const {
return _variables.thirdColumnWidth.current();
}
rpl::producer<int> thirdColumnWidthChanges() const {
return _variables.thirdColumnWidth.changes();
}

void markStickersUpdated() {
_stickersUpdated.fire({});
}
rpl::producer<> stickersUpdated() const {
return _stickersUpdated.events();
}
void markSavedGifsUpdated() {
_savedGifsUpdated.fire({});
}
rpl::producer<> savedGifsUpdated() const {
return _savedGifsUpdated.events();
}
void setDialogsWidthRatio(float64 ratio);
float64 dialogsWidthRatio() const;
rpl::producer<float64> dialogsWidthRatioChanges() const;
void setThirdColumnWidth(int width);
int thirdColumnWidth() const;
rpl::producer<int> thirdColumnWidthChanges() const;

void markStickersUpdated();
rpl::producer<> stickersUpdated() const;
void markSavedGifsUpdated();
rpl::producer<> savedGifsUpdated() const;
void setGroupStickersSectionHidden(PeerId peerId) {
_variables.groupStickersSectionHidden.insert(peerId);
}
Expand Down
11 changes: 11 additions & 0 deletions Telegram/SourceFiles/base/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,15 @@ void HandleObservables() {
}
}

rpl::producer<> ObservableViewer(base::Observable<void> &observable) {
return [&observable](const auto &consumer) {
auto lifetime = rpl::lifetime();
lifetime.make_state<base::Subscription>(
observable.add_subscription([consumer]() {
consumer.put_next({});
}));
return lifetime;
};
}

} // namespace base
12 changes: 1 addition & 11 deletions Telegram/SourceFiles/base/observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -477,16 +477,6 @@ inline auto ObservableViewer(base::Observable<Type> &observable) {
});
}

inline auto ObservableViewer(base::Observable<void> &observable) {
return rpl::make_producer<>([&observable](
const auto &consumer) {
auto lifetime = rpl::lifetime();
lifetime.make_state<base::Subscription>(
observable.add_subscription([consumer]() {
consumer.put_next({});
}));
return lifetime;
});
}
rpl::producer<> ObservableViewer(base::Observable<void> &observable);

} // namespace base
4 changes: 4 additions & 0 deletions Telegram/SourceFiles/boxes/photo_crop_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ int PhotoCropBox::mouseState(QPoint p) {
return 0;
}

rpl::producer<QImage> PhotoCropBox::ready() const {
return _readyImages.events();
}

void PhotoCropBox::mouseReleaseEvent(QMouseEvent *e) {
if (_downState) {
_downState = 0;
Expand Down
4 changes: 1 addition & 3 deletions Telegram/SourceFiles/boxes/photo_crop_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ class PhotoCropBox : public BoxContent {

int32 mouseState(QPoint p);

rpl::producer<QImage> ready() const {
return _readyImages.events();
}
rpl::producer<QImage> ready() const;

protected:
void prepare() override;
Expand Down
Loading

0 comments on commit d93c1cc

Please sign in to comment.