-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
desktopkeep-desktop GUI applicationkeep-desktop GUI applicationeasyenhancementNew feature or requestNew feature or requestmobilekeep-mobile UniFFI bindingskeep-mobile UniFFI bindingsrustPull requests that update rust codePull requests that update rust code
Description
Context
Both keep-desktop and keep-android independently implement display formatting logic that should live in Rust once and be consumed by both platforms. This was identified by comparing against the RMP Architecture Bible patterns, which calls this the "duplicated formatting logic" anti-pattern.
Current duplication
| Formatting | Desktop (Rust) | Android (Kotlin) |
|---|---|---|
| npub truncation | screen/mod.rs::truncate_npub() |
NostrFormatting.kt |
| Timestamps | screen/mod.rs::format_timestamp() |
Various inline SimpleDateFormat calls |
| Share display names | screen/shares.rs::ShareEntry::from_stored() |
ShareCards.kt |
| Hex truncation | screen/signing_audit.rs::truncate_hex() |
Inline in composables |
Proposed changes
-
Add display formatting functions to
keep-core(or a shared module both platforms already depend on):truncate_npub(npub: &str, prefix: usize, suffix: usize) -> Stringformat_timestamp(epoch_secs: u64) -> String(relative: "2 min ago", "yesterday", etc.)truncate_hex(hex: &str, len: usize) -> Stringformat_share_display_name(name: &str, group_pubkey: &[u8]) -> String
-
Update
keep-desktopscreens to call shared functions instead of local copies -
Expose via UniFFI in
keep-mobilesokeep-androidcan drop its Kotlin implementations
Benefit
Single source of truth for all user-visible string formatting. No more divergence between platforms.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
desktopkeep-desktop GUI applicationkeep-desktop GUI applicationeasyenhancementNew feature or requestNew feature or requestmobilekeep-mobile UniFFI bindingskeep-mobile UniFFI bindingsrustPull requests that update rust codePull requests that update rust code