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!
This commit is contained in:
əlemi 2024-07-06 04:37:32 +02:00
parent a901ae7656
commit 6f5b494a25
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -36,8 +36,10 @@ impl BatchFillable for Vec<RichActivity> {
}
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?;
}
}
}