The smokesignal.events web application

bug: links section should not include duplicates from facets

+23 -12
+23 -12
src/http/event_view.rs
··· 195 195 .to_string() 196 196 }); 197 197 198 + // Extract links from EventLink objects (structured links with optional titles) 199 + // These take priority over facet-extracted links 200 + let structured_links: Vec<(String, Option<String>)> = details 201 + .uris 202 + .iter() 203 + .map(|typed_link| { 204 + let link = &typed_link.inner; 205 + (link.uri.clone(), link.name.clone()) 206 + }) 207 + .collect(); 208 + 209 + // Collect structured link URIs for deduplication 210 + let structured_link_uris: HashSet<&str> = 211 + structured_links.iter().map(|(uri, _)| uri.as_str()).collect(); 212 + 198 213 // Extract facets from the event record and render HTML description 199 214 let (description_html, description_links, description_tags) = if let Some(desc_text) = 200 215 &description ··· 212 227 }); 213 228 214 229 // Extract link facets for the quick links section 230 + // Filter out links that already exist in structured links to avoid duplicates 215 231 let facet_links = facets 216 232 .as_ref() 217 233 .map(|facets_vec| { ··· 220 236 .filter_map(|facet| { 221 237 facet.features.first().and_then(|feature| { 222 238 if let atproto_record::lexicon::app::bsky::richtext::facet::FacetFeature::Link(link) = feature { 223 - Some(link.uri.clone()) 239 + // Only include if not already in structured links 240 + if !structured_link_uris.contains(link.uri.as_str()) { 241 + Some(link.uri.clone()) 242 + } else { 243 + None 244 + } 224 245 } else { 225 246 None 226 247 } ··· 362 383 }) 363 384 .unwrap_or((None, None, None)); 364 385 365 - // Extract links from EventLink objects 366 - let links = details 367 - .uris 368 - .iter() 369 - .map(|typed_link| { 370 - let link = &typed_link.inner; 371 - (link.uri.clone(), link.name.clone()) 372 - }) 373 - .collect::<Vec<_>>(); 374 - 375 386 Ok(EventView { 376 387 site_url, 377 388 aturi: event.aturi.clone(), ··· 400 411 mode, 401 412 status, 402 413 address_display, 403 - links, 414 + links: structured_links, 404 415 description_links, 405 416 description_tags, 406 417 header: header_image.clone(),