Format the local state for display. # Arguments `entries` - Local history entries # Returns A formatted string like "at ABC123... (10 changes)" or "(empty)".
(entries: &[HistoryEntry])
| 334 | /// |
| 335 | /// A formatted string like "at ABC123... (10 changes)" or "(empty)". |
| 336 | fn format_local_state(entries: &[HistoryEntry]) -> String { |
| 337 | if entries.is_empty() { |
| 338 | return hint("(empty)").to_string(); |
| 339 | } |
| 340 | |
| 341 | if let Some(last) = entries.last() { |
| 342 | let hash_str = last.hash.to_base32(); |
| 343 | let hash_short = &hash_str[..12.min(hash_str.len())]; |
| 344 | format!( |
| 345 | "at {}... ({} {})", |
| 346 | hint(hash_short), |
| 347 | entries.len(), |
| 348 | if entries.len() == 1 { |
| 349 | "change" |
| 350 | } else { |
| 351 | "changes" |
| 352 | } |
| 353 | ) |
| 354 | } else { |
| 355 | hint("(empty)").to_string() |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | /// Format the remote state for display. |
| 360 | /// |