Skip to content

Commit

Permalink
fix: don't display 0 ICP of rewards in the notification
Browse files Browse the repository at this point in the history
  • Loading branch information
X committed May 17, 2024
1 parent d840aa4 commit 6fc4f5c
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/backend/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,11 +1404,26 @@ impl State {
total_rewards += user_reward;
total_revenue += user_revenue;
items.push((e8s, user.name.clone()));
user.notify(format!(
"You received `{}` ICP as rewards and `{}` ICP as revenue! 💸",
display_tokens(user_reward, 8),
display_tokens(user_revenue, 8)
));
if user_reward > 0 || user_revenue > 0 {
let mut notification = String::from("You received ");
if user_reward > 0 {
notification.push_str(&format!(
"`{}` ICP as rewards",
display_tokens(user_reward, 8)
));
}
if user_revenue > 0 {
if user_reward > 0 {
notification.push_str(" and ");
}
notification.push_str(&format!(
"`{}` ICP as revenue",
display_tokens(user_revenue, 8)
));
}
notification.push_str("! 💸");
user.notify(notification);
}
}
if self.burned_cycles > 0 {
self.spend(self.burned_cycles as Credits, "revenue distribution");
Expand Down

0 comments on commit 6fc4f5c

Please sign in to comment.