From 6f5b494a25706cb735c7afe8a76cfc63ad0631a3 Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 6 Jul 2024 04:37:32 +0200 Subject: [PATCH] fix: batch load fills multiple identical objects in case of an announce and a view, we get the attachments only once otherwise and frontend may overwrite cache with the empty one. this is wasteful because we clone everytime tho, TODO! --- upub/core/src/selector/batch.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/upub/core/src/selector/batch.rs b/upub/core/src/selector/batch.rs index 3892cd6..6db7959 100644 --- a/upub/core/src/selector/batch.rs +++ b/upub/core/src/selector/batch.rs @@ -36,8 +36,10 @@ impl BatchFillable for Vec { } for element in self.iter_mut() { if let Some(ref object) = element.object { - if let Some(v) = map.remove(&object.internal) { - element.accept(v, tx).await?; + if let Some(v) = map.get(&object.internal) { + // TODO wasteful because we clone every time, but we cant do remove otherwise multiple + // identical objects wont get filled (for example, a post boosted twice) + element.accept(v.clone(), tx).await?; } } }