mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
conversation: emit ConversationSyncFinished when all fetches done
Change-Id: If2c5e86a160998ddc25e095bba1de3add89f37e0
This commit is contained in:
@ -953,12 +953,8 @@ Conversation::Impl::pull()
|
||||
decltype(fetchingRemotes_.begin()) it;
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(pullcbsMtx_);
|
||||
if (pullcbs_.empty()) {
|
||||
if (auto account = account_.lock())
|
||||
emitSignal<DRing::ConversationSignal::ConversationSyncFinished>(
|
||||
account->getAccountID().c_str());
|
||||
if (pullcbs_.empty())
|
||||
return;
|
||||
}
|
||||
auto& elem = pullcbs_.front();
|
||||
deviceId = std::move(std::get<0>(elem));
|
||||
commitId = std::move(std::get<1>(elem));
|
||||
|
@ -269,6 +269,7 @@ public:
|
||||
std::mutex replayMtx_;
|
||||
std::map<std::string, std::vector<std::map<std::string, std::string>>> replay_;
|
||||
std::map<std::string, uint64_t> refreshMessage;
|
||||
std::atomic_int syncCnt {0};
|
||||
};
|
||||
|
||||
ConversationModule::Impl::Impl(std::weak_ptr<JamiAccount>&& account,
|
||||
@ -418,6 +419,7 @@ ConversationModule::Impl::fetchNewCommits(const std::string& peer,
|
||||
return false;
|
||||
}
|
||||
acc->addGitSocket(channel->deviceId(), conversationId, channel);
|
||||
syncCnt.fetch_add(1);
|
||||
conversation->second->sync(
|
||||
peer,
|
||||
deviceId,
|
||||
@ -438,8 +440,15 @@ ConversationModule::Impl::fetchNewCommits(const std::string& peer,
|
||||
deviceId.c_str(),
|
||||
conversationId.c_str());
|
||||
}
|
||||
std::lock_guard<std::mutex> lk(pendingConversationsFetchMtx_);
|
||||
pendingConversationsFetch_.erase(conversationId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(pendingConversationsFetchMtx_);
|
||||
pendingConversationsFetch_.erase(conversationId);
|
||||
}
|
||||
if (syncCnt.fetch_sub(1) == 1) {
|
||||
if (auto account = account_.lock())
|
||||
emitSignal<DRing::ConversationSignal::ConversationSyncFinished>(
|
||||
account->getAccountID().c_str());
|
||||
}
|
||||
},
|
||||
commitId);
|
||||
return true;
|
||||
@ -1367,6 +1376,10 @@ ConversationModule::syncConversations(const std::string& peer, const std::string
|
||||
pimpl_->fetchNewCommits(peer, deviceId, cid);
|
||||
for (const auto& cid : toClone)
|
||||
pimpl_->cloneConversation(deviceId, peer, cid);
|
||||
if (pimpl_->syncCnt.load() == 0) {
|
||||
if (auto acc = pimpl_->account_.lock())
|
||||
emitSignal<DRing::ConversationSignal::ConversationSyncFinished>(acc->getAccountID().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user