mirror of
https://seed.radicle.dev/rad:z39mP9rQAaGmERfUMPULfPUi473tY.git
synced 2026-11-28 22:10:27 +08:00
bin: Fix varying reaction order in comment item
This commit is contained in:
+9
-5
@@ -954,17 +954,21 @@ impl CommentItem {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn accumulated_reactions(&self) -> HashMap<char, usize> {
|
||||
let mut reactions: HashMap<char, usize> = HashMap::new();
|
||||
pub fn accumulated_reactions(&self) -> Vec<(char, usize)> {
|
||||
let mut accumulated: HashMap<char, usize> = HashMap::new();
|
||||
|
||||
for reaction in &self.reactions {
|
||||
if let Some(count) = reactions.get_mut(reaction) {
|
||||
if let Some(count) = accumulated.get_mut(reaction) {
|
||||
*count = count.saturating_add(1);
|
||||
} else {
|
||||
reactions.insert(*reaction, 1_usize);
|
||||
accumulated.insert(*reaction, 1_usize);
|
||||
}
|
||||
}
|
||||
|
||||
reactions
|
||||
let mut sorted = accumulated.into_iter().collect::<Vec<_>>();
|
||||
sorted.sort();
|
||||
|
||||
sorted
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user