Format the local state for display. # Arguments `entries` - Local history entries # Returns A formatted string like "at ABC123... (10 changes)" or "(empty)".
(entries: &[HistoryEntry])
| 352 | /// |
| 353 | /// A formatted string like "at ABC123... (10 changes)" or "(empty)". |
| 354 | fn format_local_state(entries: &[HistoryEntry]) -> String { |
| 355 | if entries.is_empty() { |
| 356 | return hint("(empty)").to_string(); |
| 357 | } |
| 358 | |
| 359 | if let Some(last) = entries.last() { |
| 360 | let hash_str = last.hash.to_base32(); |
| 361 | let hash_short = &hash_str[..12.min(hash_str.len())]; |
| 362 | format!( |
| 363 | "at {}... ({} {})", |
| 364 | hint(hash_short), |
| 365 | entries.len(), |
| 366 | if entries.len() == 1 { |
| 367 | "change" |
| 368 | } else { |
| 369 | "changes" |
| 370 | } |
| 371 | ) |
| 372 | } else { |
| 373 | hint("(empty)").to_string() |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | /// Format the remote state for display. |
| 378 | /// |