Load all read stories from time to time.

This commit is contained in:
levlam 2023-07-07 17:41:30 +03:00
parent 987faa7c6a
commit 288666c1fe
3 changed files with 29 additions and 0 deletions

View File

@ -123,6 +123,28 @@ class ToggleStoriesHiddenQuery final : public Td::ResultHandler {
} }
}; };
class GetAllReadUserStoriesQuery final : public Td::ResultHandler {
public:
void send() {
send_query(G()->net_query_creator().create(telegram_api::stories_getAllReadUserStories()));
}
void on_result(BufferSlice packet) final {
auto result_ptr = fetch_result<telegram_api::stories_getAllReadUserStories>(packet);
if (result_ptr.is_error()) {
return on_error(result_ptr.move_as_error());
}
auto ptr = result_ptr.move_as_ok();
LOG(DEBUG) << "Receive result for GetAllReadUserStoriesQuery: " << to_string(ptr);
td_->updates_manager_->on_get_updates(std::move(ptr), Promise<Unit>());
}
void on_error(Status status) final {
LOG(INFO) << "Failed to get all read user stories: " << status;
}
};
class ToggleAllStoriesHiddenQuery final : public Td::ResultHandler { class ToggleAllStoriesHiddenQuery final : public Td::ResultHandler {
Promise<Unit> promise_; Promise<Unit> promise_;
@ -1104,6 +1126,10 @@ void StoryManager::on_load_active_stories(
set_promises(promises); set_promises(promises);
} }
void StoryManager::reload_all_read_stories() {
td_->create_handler<GetAllReadUserStoriesQuery>()->send();
}
void StoryManager::try_synchronize_archive_all_stories() { void StoryManager::try_synchronize_archive_all_stories() {
if (G()->close_flag()) { if (G()->close_flag()) {
return; return;

View File

@ -158,6 +158,8 @@ class StoryManager final : public Actor {
void reload_active_stories(); void reload_active_stories();
void reload_all_read_stories();
void toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise); void toggle_dialog_stories_hidden(DialogId dialog_id, bool are_hidden, Promise<Unit> &&promise);
void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit, void get_dialog_pinned_stories(DialogId owner_dialog_id, StoryId from_story_id, int32 limit,

View File

@ -2171,6 +2171,7 @@ void UpdatesManager::try_reload_data() {
td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(false, true, Auto()); td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(false, true, Auto());
td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(true, true, Auto()); td_->stickers_manager_->get_default_dialog_photo_custom_emoji_stickers(true, true, Auto());
td_->story_manager_->reload_active_stories(); td_->story_manager_->reload_active_stories();
td_->story_manager_->reload_all_read_stories();
schedule_data_reload(); schedule_data_reload();
} }