Skip to content
This repository was archived by the owner on Feb 3, 2025. It is now read-only.

Commit cbefe8b

Browse files
committed
Add primal image url to wasm model
1 parent a8b07f5 commit cbefe8b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mutiny-wasm/src/models.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ pub struct TagItem {
695695
lnurl: Option<LnUrl>,
696696
#[serde(skip_serializing_if = "Option::is_none")]
697697
image_url: Option<String>,
698+
#[serde(skip_serializing_if = "Option::is_none")]
699+
primal_image_url: Option<String>,
698700
/// Epoch time in seconds when this tag was last used
699701
pub last_used_time: u64,
700702
}
@@ -753,6 +755,11 @@ impl TagItem {
753755
pub fn image_url(&self) -> Option<String> {
754756
self.image_url.clone()
755757
}
758+
759+
#[wasm_bindgen(getter)]
760+
pub fn primal_image_url(&self) -> Option<String> {
761+
self.primal_image_url.clone()
762+
}
756763
}
757764

758765
impl From<(String, MutinyContact)> for TagItem {
@@ -764,6 +771,12 @@ impl From<(String, MutinyContact)> for TagItem {
764771
npub: contact.npub.map(|n| n.to_bech32().expect("bech32")),
765772
ln_address: contact.ln_address,
766773
lnurl: contact.lnurl,
774+
primal_image_url: contact.image_url.as_ref().map(|i| {
775+
format!(
776+
"https://primal.b-cdn.net/media-cache?s=s&a=1&u={}",
777+
urlencoding::encode(i)
778+
)
779+
}),
767780
image_url: contact.image_url,
768781
last_used_time: contact.last_used,
769782
}
@@ -781,6 +794,7 @@ impl From<labels::TagItem> for TagItem {
781794
ln_address: None,
782795
lnurl: None,
783796
image_url: None,
797+
primal_image_url: None,
784798
last_used_time: item.last_used_time,
785799
},
786800
labels::TagItem::Contact(contact) => contact.into(),

0 commit comments

Comments
 (0)