mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Don't show recent apps in popular apps.
This commit is contained in:
parent
7f3dc27aa9
commit
11c91c1a42
2 changed files with 49 additions and 15 deletions
|
@ -429,11 +429,15 @@ public:
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<> refreshed() const;
|
||||||
|
[[nodiscard]] bool shown(not_null<PeerData*> peer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void appendRow(not_null<UserData*> bot);
|
void appendRow(not_null<UserData*> bot);
|
||||||
void fill();
|
void fill();
|
||||||
|
|
||||||
std::vector<not_null<UserData*>> _bots;
|
std::vector<not_null<UserData*>> _bots;
|
||||||
|
rpl::event_stream<> _refreshed;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -442,7 +446,9 @@ class PopularAppsController final
|
||||||
: public Suggestions::ObjectListController {
|
: public Suggestions::ObjectListController {
|
||||||
public:
|
public:
|
||||||
explicit PopularAppsController(
|
explicit PopularAppsController(
|
||||||
not_null<Window::SessionController*> window);
|
not_null<Window::SessionController*> window,
|
||||||
|
Fn<bool(not_null<PeerData*>)> filterOut,
|
||||||
|
rpl::producer<> filterOutRefreshes);
|
||||||
|
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
||||||
|
@ -452,6 +458,8 @@ private:
|
||||||
void fill();
|
void fill();
|
||||||
void appendRow(not_null<UserData*> bot);
|
void appendRow(not_null<UserData*> bot);
|
||||||
|
|
||||||
|
Fn<bool(not_null<PeerData*>)> _filterOut;
|
||||||
|
rpl::producer<> _filterOutRefreshes;
|
||||||
History *_activeHistory = nullptr;
|
History *_activeHistory = nullptr;
|
||||||
bool _requested = false;
|
bool _requested = false;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
@ -1068,6 +1076,14 @@ void RecentAppsController::load() {
|
||||||
session().topBotApps().reload();
|
session().topBotApps().reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<> RecentAppsController::refreshed() const {
|
||||||
|
return _refreshed.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RecentAppsController::shown(not_null<PeerData*> peer) const {
|
||||||
|
return delegate()->peerListFindRow(peer->id.value) != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void RecentAppsController::fill() {
|
void RecentAppsController::fill() {
|
||||||
const auto count = countCurrent();
|
const auto count = countCurrent();
|
||||||
const auto limit = expandedCurrent()
|
const auto limit = expandedCurrent()
|
||||||
|
@ -1087,6 +1103,8 @@ void RecentAppsController::fill() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
|
|
||||||
|
_refreshed.fire({});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecentAppsController::appendRow(not_null<UserData*> bot) {
|
void RecentAppsController::appendRow(not_null<UserData*> bot) {
|
||||||
|
@ -1099,13 +1117,21 @@ void RecentAppsController::appendRow(not_null<UserData*> bot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PopularAppsController::PopularAppsController(
|
PopularAppsController::PopularAppsController(
|
||||||
not_null<Window::SessionController*> window)
|
not_null<Window::SessionController*> window,
|
||||||
: ObjectListController(window) {
|
Fn<bool(not_null<PeerData*>)> filterOut,
|
||||||
|
rpl::producer<> filterOutRefreshes)
|
||||||
|
: ObjectListController(window)
|
||||||
|
, _filterOut(std::move(filterOut))
|
||||||
|
, _filterOutRefreshes(std::move(filterOutRefreshes)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopularAppsController::prepare() {
|
void PopularAppsController::prepare() {
|
||||||
setupPlainDivider(tr::lng_bot_apps_popular());
|
setupPlainDivider(tr::lng_bot_apps_popular());
|
||||||
fill();
|
rpl::single() | rpl::then(
|
||||||
|
std::move(_filterOutRefreshes)
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
fill();
|
||||||
|
}, _lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopularAppsController::load() {
|
void PopularAppsController::load() {
|
||||||
|
@ -1122,13 +1148,13 @@ void PopularAppsController::load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopularAppsController::fill() {
|
void PopularAppsController::fill() {
|
||||||
const auto attachWebView = &session().attachWebView();
|
while (delegate()->peerListFullRowsCount()) {
|
||||||
const auto &list = attachWebView->popularAppBots();
|
delegate()->peerListRemoveRow(delegate()->peerListRowAt(0));
|
||||||
if (list.empty()) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
for (const auto &bot : list) {
|
for (const auto &bot : session().attachWebView().popularAppBots()) {
|
||||||
appendRow(bot);
|
if (!_filterOut || !_filterOut(bot)) {
|
||||||
|
appendRow(bot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
setCount(delegate()->peerListFullRowsCount());
|
setCount(delegate()->peerListFullRowsCount());
|
||||||
|
@ -1136,10 +1162,10 @@ void PopularAppsController::fill() {
|
||||||
|
|
||||||
void PopularAppsController::appendRow(not_null<UserData*> bot) {
|
void PopularAppsController::appendRow(not_null<UserData*> bot) {
|
||||||
auto row = std::make_unique<PeerListRow>(bot);
|
auto row = std::make_unique<PeerListRow>(bot);
|
||||||
if (const auto count = bot->botInfo->activeUsers) {
|
//if (const auto count = bot->botInfo->activeUsers) {
|
||||||
row->setCustomStatus(
|
// row->setCustomStatus(
|
||||||
tr::lng_bot_status_users(tr::now, lt_count_decimal, count));
|
// tr::lng_bot_status_users(tr::now, lt_count_decimal, count));
|
||||||
}
|
//}
|
||||||
delegate()->peerListAppendRow(std::move(row));
|
delegate()->peerListAppendRow(std::move(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1896,6 +1922,10 @@ auto Suggestions::setupRecommendations() -> std::unique_ptr<ObjectList> {
|
||||||
auto Suggestions::setupRecentApps() -> std::unique_ptr<ObjectList> {
|
auto Suggestions::setupRecentApps() -> std::unique_ptr<ObjectList> {
|
||||||
const auto controller = lifetime().make_state<RecentAppsController>(
|
const auto controller = lifetime().make_state<RecentAppsController>(
|
||||||
_controller);
|
_controller);
|
||||||
|
_recentAppsShows = [=](not_null<PeerData*> peer) {
|
||||||
|
return controller->shown(peer);
|
||||||
|
};
|
||||||
|
_recentAppsRefreshed = controller->refreshed();
|
||||||
|
|
||||||
auto result = setupObjectList(
|
auto result = setupObjectList(
|
||||||
_appsScroll.get(),
|
_appsScroll.get(),
|
||||||
|
@ -1952,7 +1982,9 @@ auto Suggestions::setupRecentApps() -> std::unique_ptr<ObjectList> {
|
||||||
|
|
||||||
auto Suggestions::setupPopularApps() -> std::unique_ptr<ObjectList> {
|
auto Suggestions::setupPopularApps() -> std::unique_ptr<ObjectList> {
|
||||||
const auto controller = lifetime().make_state<PopularAppsController>(
|
const auto controller = lifetime().make_state<PopularAppsController>(
|
||||||
_controller);
|
_controller,
|
||||||
|
_recentAppsShows,
|
||||||
|
rpl::duplicate(_recentAppsRefreshed));
|
||||||
|
|
||||||
const auto addToScroll = [=] {
|
const auto addToScroll = [=] {
|
||||||
const auto wrap = _recentApps->wrap;
|
const auto wrap = _recentApps->wrap;
|
||||||
|
|
|
@ -189,6 +189,8 @@ private:
|
||||||
const std::unique_ptr<Ui::ElasticScroll> _appsScroll;
|
const std::unique_ptr<Ui::ElasticScroll> _appsScroll;
|
||||||
const not_null<Ui::VerticalLayout*> _appsContent;
|
const not_null<Ui::VerticalLayout*> _appsContent;
|
||||||
|
|
||||||
|
rpl::producer<> _recentAppsRefreshed;
|
||||||
|
Fn<bool(not_null<PeerData*>)> _recentAppsShows;
|
||||||
const std::unique_ptr<ObjectList> _recentApps;
|
const std::unique_ptr<ObjectList> _recentApps;
|
||||||
const std::unique_ptr<ObjectList> _popularApps;
|
const std::unique_ptr<ObjectList> _popularApps;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue