diff --git a/ssr/src/component/video_player.rs b/ssr/src/component/video_player.rs index 2b4466f1..2da2abdf 100644 --- a/ssr/src/component/video_player.rs +++ b/ssr/src/component/video_player.rs @@ -1,5 +1,5 @@ use leptos::*; -use leptos_dom::{html::Video, NodeRef}; +use leptos_dom::html::Video; #[component] pub fn VideoPlayer( diff --git a/ssr/src/consts/mod.rs b/ssr/src/consts/mod.rs index 1dac08f2..7e7430a0 100644 --- a/ssr/src/consts/mod.rs +++ b/ssr/src/consts/mod.rs @@ -13,6 +13,9 @@ use reqwest::Url; pub const CF_STREAM_BASE: &str = "https://customer-2p3jflss4r4hmpnz.cloudflarestream.com"; pub const FALLBACK_PROPIC_BASE: &str = "https://api.dicebear.com/7.x/big-smile/svg"; +// an example URL is "https://imagedelivery.net/abXI9nS4DYYtyR1yFFtziA/gob.5/public"; +pub const GOBGOB_PROPIC_URL: &str = "https://imagedelivery.net/abXI9nS4DYYtyR1yFFtziA/gob."; +pub const GOBGOB_TOTAL_COUNT: u32 = 18557; pub const CF_WATERMARK_UID: &str = "c094ef579b950a6a5ae3e482268b81ca"; pub const ACCOUNT_CONNECTED_STORE: &str = "account-connected-1"; pub static CF_BASE_URL: Lazy = diff --git a/ssr/src/utils/profile.rs b/ssr/src/utils/profile.rs index 19c95f75..78b20382 100644 --- a/ssr/src/utils/profile.rs +++ b/ssr/src/utils/profile.rs @@ -9,7 +9,7 @@ use crate::{ UserProfileDetailsForFrontend, }, component::infinite_scroller::{CursoredDataProvider, KeyedData, PageEntry}, - consts::FALLBACK_PROPIC_BASE, + consts::{GOBGOB_PROPIC_URL, GOBGOB_TOTAL_COUNT}, state::canisters::Canisters, }; @@ -44,9 +44,9 @@ impl From for ProfileDetails { } } -fn color_from_principal(principal: Principal) -> String { - let col_int = crc32fast::hash(principal.as_slice()) & 0xFFFFFF; - format!("{col_int:06x}") +fn index_from_principal(principal: Principal) -> u32 { + let hash_value = crc32fast::hash(principal.as_slice()); + (hash_value % GOBGOB_TOTAL_COUNT) + 1 } impl ProfileDetails { @@ -63,22 +63,18 @@ impl ProfileDetails { } pub fn profile_pic_or_random(&self) -> String { - let propic = self.profile_pic.clone().unwrap_or_default(); - if !propic.is_empty() { - return propic; - } + // let propic = self.profile_pic.clone().unwrap_or_default(); + // if !propic.is_empty() { + // return propic; + // } propic_from_principal(self.principal) } } pub fn propic_from_principal(principal: Principal) -> String { - let background_color = color_from_principal(principal); - format!( - "{FALLBACK_PROPIC_BASE}?seed={}&backgroundColor={}&backgroundType=solid", - principal.to_text(), - background_color - ) + let index = index_from_principal(principal); + format!("{GOBGOB_PROPIC_URL}{}/public", index) } #[derive(Clone, Copy)]