summaryrefslogtreecommitdiff
path: root/src/account.cc
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2014-04-19 21:56:14 -0700
committerCraig Earls <enderw88@gmail.com>2014-04-19 21:56:14 -0700
commitfd18f58392833d6e1b1c06a7700f8afc37711c87 (patch)
tree895daa013b63caeed47bd944daba89003e9b34ce /src/account.cc
parent7faaeb301fe524422c694e54fa36248ffedfa9b8 (diff)
parenta0c5addbbdaf472d26ae25c86ff826e509b3ee17 (diff)
downloadfork-ledger-fd18f58392833d6e1b1c06a7700f8afc37711c87.tar.gz
fork-ledger-fd18f58392833d6e1b1c06a7700f8afc37711c87.tar.bz2
fork-ledger-fd18f58392833d6e1b1c06a7700f8afc37711c87.zip
Merge commit 'a0c5addbbdaf472d26ae25c86ff826e509b3ee17'
Diffstat (limited to 'src/account.cc')
-rw-r--r--src/account.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/account.cc b/src/account.cc
index 4b3a4e97..216b15bd 100644
--- a/src/account.cc
+++ b/src/account.cc
@@ -139,6 +139,36 @@ void account_t::add_post(post_t * post)
}
}
+void account_t::add_deferred_post(const string& uuid, post_t * post)
+{
+ if (! deferred_posts)
+ deferred_posts = deferred_posts_map_t();
+
+ deferred_posts_map_t::iterator i = deferred_posts->find(uuid);
+ if (i == deferred_posts->end()) {
+ posts_list lst;
+ lst.push_back(post);
+ deferred_posts->insert(deferred_posts_map_t::value_type(uuid, lst));
+ } else {
+ (*i).second.push_back(post);
+ }
+}
+
+void account_t::apply_deferred_posts()
+{
+ if (deferred_posts) {
+ foreach (deferred_posts_map_t::value_type& pair, *deferred_posts) {
+ foreach (post_t * post, pair.second)
+ post->account->add_post(post);
+ }
+ deferred_posts = none;
+ }
+
+ // Also apply in child accounts
+ foreach (const accounts_map::value_type& pair, accounts)
+ pair.second->apply_deferred_posts();
+}
+
bool account_t::remove_post(post_t * post)
{
// It's possible that 'post' wasn't yet in this account, but try to