void tpanel_subtweet_pending_op::CheckLoadQuotedTweet(tweet_ptr_p quote_tweet, wxSizer *v, tpanelparentwin_nt *s, tweetdispscr *parent_tds) { using GUAF = tweet::GUAF; if (parent_tds->td->IsArrivedHereAnyPerspective() || parent_tds->td->lflags & TLF::SHOULDSAVEINDB) { quote_tweet->SaveToDB(); } std::shared_ptr<taccount> pacc; parent_tds->td->GetUsableAccount(pacc, GUAF::NOERR) || parent_tds->td->GetUsableAccount(pacc, GUAF::NOERR | GUAF::USERENABLED); quote_tweet->AddNewPendingOp(std::unique_ptr<pending_op>(new tpanel_subtweet_pending_op(v, s, parent_tds, 0, tspo_type::QUOTE))); CheckFetchPendingSingleTweet(quote_tweet, pacc); TryUnmarkPendingTweet(quote_tweet, 0); }
void tpanel_subtweet_pending_op::CheckLoadTweetReply(tweet_ptr_p t, wxSizer *v, tpanelparentwin_nt *s, tweetdispscr *tds, unsigned int load_count, tweetdispscr *parent_tds) { using GUAF = tweet::GUAF; uint64_t reply_id = t->in_reply_to_status_id; uint64_t reply_user_id = t->in_reply_to_user_id; if (!reply_id && t->rtsrc) { reply_id = t->rtsrc->in_reply_to_status_id; reply_user_id = t->rtsrc->in_reply_to_user_id; } if (reply_id) { std::function<void(unsigned int)> loadmorefunc = [=](unsigned int tweet_load_count) { tweet_ptr subt = ad.GetTweetById(reply_id); if (parent_tds->td->IsArrivedHereAnyPerspective() || parent_tds->td->lflags & TLF::SHOULDSAVEINDB) { subt->SaveToDB(); } std::shared_ptr<taccount> pacc; t->GetUsableAccount(pacc, GUAF::NOERR) || t->GetUsableAccount(pacc, GUAF::NOERR | GUAF::USERENABLED); if (reply_user_id) { GetUsableAccountFollowingUser(pacc, reply_user_id); } subt->AddNewPendingOp(std::unique_ptr<pending_op>(new tpanel_subtweet_pending_op(v, s, parent_tds, tweet_load_count, tspo_type::INLINE_REPLY))); CheckFetchPendingSingleTweet(subt, pacc); TryUnmarkPendingTweet(subt, 0); }; if (load_count == 0) { tds->tds_flags |= TDSF::CANLOADMOREREPLIES; tds->loadmorereplies = [=]() { loadmorefunc(gc.inlinereplyloadmorecount); }; return; } else loadmorefunc(load_count); } }
void filter_dlg::ExecFilter() { std::unique_ptr<dbseltweetmsg> loadmsg; SetNoUpdateFlag_All(); fdg->shared_state->apply_filter.EnableUndo(); tweetidset dbset; for (auto id : fdg->selectedset) { optional_tweet_ptr tobj = ad.GetExistingTweetById(id); if (!tobj) { if (ad.unloaded_db_tweet_ids.find(id) != ad.unloaded_db_tweet_ids.end()) { // This is in DB dbset.insert(id); continue; } // fallback, shouldn't happen too often tobj = ad.GetTweetById(id); } if (CheckFetchPendingSingleTweet(tobj, std::shared_ptr<taccount>(), &loadmsg, PENDING_REQ::USEREXPIRE, PENDING_RESULT::CONTENT_READY)) { FilterOneTweet(fdg->shared_state->apply_filter, tobj); } else { tobj->AddNewPendingOp(std::unique_ptr<pending_op>(new applyfilter_pending_op(fdg->shared_state))); } } if (loadmsg) { loadmsg->flags |= DBSTMF::CLEARNOUPDF; DBC_PrepareStdTweetLoadMsg(*loadmsg); DBC_SendMessage(std::move(loadmsg)); } else { CheckClearNoUpdateFlag_All(); } if (!dbset.empty()) { filter_set fs; LoadFilter(fdg->shared_state->apply_filter.filter_text, fs); // Do not send shared_state to the completion callback/DB thread, as this would // cause major problems if for whatever reason a reply was not sent and the message and // thus callback was destructed in the DB thread, in the case where it held the last reference // to the shared_state. The shared_state destructor may not be run in the DB thread. static std::map<uint64_t, std::shared_ptr<filter_dlg_shared_state>> pending_db_filters; static uint64_t next_id; uint64_t this_id = next_id++; pending_db_filters[this_id] = fdg->shared_state; filter_set::DBFilterTweetIDs(std::move(fs), std::move(dbset), true, [this_id](std::unique_ptr<undo::action> undo) { auto it = pending_db_filters.find(this_id); if (it != pending_db_filters.end()) { it->second->db_undo_action = std::move(undo); pending_db_filters.erase(it); LogMsgFormat(LOGT::FILTERTRACE, "filter_dlg::ExecFilter: DB filter complete, %zu pending", pending_db_filters.size()); } else { LogMsgFormat(LOGT::FILTERERR, "filter_dlg::ExecFilter: DB filter completion: item missing from pending_db_filters!"); } }); } }