state is now saved on every last post change

This commit is contained in:
Slavasil 2024-11-27 00:27:45 +03:00
parent c0d90d2341
commit 9b758c6fb8

View File

@ -108,6 +108,7 @@ void NewPostFetcher::fetch() {
if (posts.size() > 0) {
spdlog::info("last vk post id is now {}", posts[0].id);
mgr->m_appState->vkLastLoadedPostId = posts[0].id;
mgr->m_appState->save();
}
vkState.ready = true;
std::vector<AbstractPost> aposts = mgr->to_abstract_posts(posts);
@ -137,6 +138,7 @@ void NewPostFetcher::fetch() {
if (posts.size() > 0) {
spdlog::info("last telegram post id is now {}", posts[0]->id_);
mgr->m_appState->tgLastLoadedPostId = posts[0]->id_;
mgr->m_appState->save();
}
tgState.ready = true;
std::vector<AbstractPost> aposts = mgr->to_abstract_posts(posts);
@ -170,6 +172,7 @@ void NewPostFetcher::check_vk_posts(std::vector<vk::Post> posts) {
if (vkState.ready && !vkState.posts.empty()) {
spdlog::debug("last loaded vk post id is now {}", vkState.posts[0].id);
mgr->m_appState->vkLastLoadedPostId = vkState.posts[0].id;
mgr->m_appState->save();
}
fetch();
}
@ -193,6 +196,7 @@ void NewPostFetcher::check_tg_posts(std::vector<td::tl::unique_ptr<td_api::messa
if (tgState.ready && !tgState.posts.empty()) {
spdlog::debug("last loaded tg post id is now {}", tgState.posts[0].id);
mgr->m_appState->tgLastLoadedPostId = tgState.posts[0].id;
mgr->m_appState->save();
}
fetch();
}
@ -420,6 +424,7 @@ void RepostManager::repost(AbstractPost &post) {
m_appState->vkLastPostId = postId;
else
m_appState->tgLastPostId = postId;
m_appState->save();
}
});
}