From f62a71dce2f31b44e968638c243561923f246dd7 Mon Sep 17 00:00:00 2001 From: debjit Date: Thu, 1 Aug 2024 20:57:33 +0530 Subject: [PATCH 1/5] changed avatars to gobgob images from cloudflare --- ssr/src/consts/mod.rs | 3 +++ ssr/src/utils/profile.rs | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ssr/src/consts/mod.rs b/ssr/src/consts/mod.rs index 1dac08f2..d3a0ccc3 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 = 5000; 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..cbfdbb9c 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::{FALLBACK_PROPIC_BASE, GOBGOB_TOTAL_COUNT, GOBGOB_PROPIC_URL}, state::canisters::Canisters, }; @@ -49,6 +49,12 @@ fn color_from_principal(principal: Principal) -> String { format!("{col_int:06x}") } +fn index_from_principal(principal: Principal) -> u32 { + let hash_value = crc32fast::hash(principal.as_slice()); + let number = (hash_value % GOBGOB_TOTAL_COUNT) + 1; + number +} + impl ProfileDetails { pub fn username_or_principal(&self) -> String { self.username @@ -73,11 +79,10 @@ impl ProfileDetails { } pub fn propic_from_principal(principal: Principal) -> String { - let background_color = color_from_principal(principal); + let index = index_from_principal(principal); format!( - "{FALLBACK_PROPIC_BASE}?seed={}&backgroundColor={}&backgroundType=solid", - principal.to_text(), - background_color + "{GOBGOB_PROPIC_URL}{}/public", + index.to_string() ) } From f98efdc62cea25a82e0507eb42571b6d7c8f23aa Mon Sep 17 00:00:00 2001 From: debjit Date: Thu, 1 Aug 2024 21:53:47 +0530 Subject: [PATCH 2/5] upped limit of number of gobgobs --- ssr/src/consts/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssr/src/consts/mod.rs b/ssr/src/consts/mod.rs index d3a0ccc3..bdfbbf8a 100644 --- a/ssr/src/consts/mod.rs +++ b/ssr/src/consts/mod.rs @@ -15,7 +15,7 @@ pub const CF_STREAM_BASE: &str = "https://customer-2p3jflss4r4hmpnz.cloudflarest 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 = 5000; +pub const GOBGOB_TOTAL_COUNT: u32 = 8000; pub const CF_WATERMARK_UID: &str = "c094ef579b950a6a5ae3e482268b81ca"; pub const ACCOUNT_CONNECTED_STORE: &str = "account-connected-1"; pub static CF_BASE_URL: Lazy = From a1cca84447453aa4f677d6f5d916d41eaa1212c2 Mon Sep 17 00:00:00 2001 From: debjit Date: Fri, 2 Aug 2024 09:28:28 +0530 Subject: [PATCH 3/5] show gobgob for existing users --- ssr/src/utils/profile.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ssr/src/utils/profile.rs b/ssr/src/utils/profile.rs index cbfdbb9c..5d9f4c42 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, GOBGOB_TOTAL_COUNT, GOBGOB_PROPIC_URL}, + consts::{FALLBACK_PROPIC_BASE, GOBGOB_PROPIC_URL, GOBGOB_TOTAL_COUNT}, state::canisters::Canisters, }; @@ -69,10 +69,10 @@ 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) } @@ -80,10 +80,7 @@ impl ProfileDetails { pub fn propic_from_principal(principal: Principal) -> String { let index = index_from_principal(principal); - format!( - "{GOBGOB_PROPIC_URL}{}/public", - index.to_string() - ) + format!("{GOBGOB_PROPIC_URL}{}/public", index.to_string()) } #[derive(Clone, Copy)] From 2661f39b6d3f92437601f1272ca373068d473414 Mon Sep 17 00:00:00 2001 From: debjit Date: Fri, 2 Aug 2024 09:48:53 +0530 Subject: [PATCH 4/5] uploaded all images, modulus increased --- ssr/src/consts/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssr/src/consts/mod.rs b/ssr/src/consts/mod.rs index bdfbbf8a..7e7430a0 100644 --- a/ssr/src/consts/mod.rs +++ b/ssr/src/consts/mod.rs @@ -15,7 +15,7 @@ pub const CF_STREAM_BASE: &str = "https://customer-2p3jflss4r4hmpnz.cloudflarest 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 = 8000; +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 = From bd31ec61e14e0ecdb4e512979899429eaaa0f5a8 Mon Sep 17 00:00:00 2001 From: debjit Date: Fri, 2 Aug 2024 13:14:12 +0530 Subject: [PATCH 5/5] linter complaints fixed --- ssr/src/component/video_player.rs | 2 +- ssr/src/utils/profile.rs | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) 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/utils/profile.rs b/ssr/src/utils/profile.rs index 5d9f4c42..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, GOBGOB_PROPIC_URL, GOBGOB_TOTAL_COUNT}, + consts::{GOBGOB_PROPIC_URL, GOBGOB_TOTAL_COUNT}, state::canisters::Canisters, }; @@ -44,15 +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()); - let number = (hash_value % GOBGOB_TOTAL_COUNT) + 1; - number + (hash_value % GOBGOB_TOTAL_COUNT) + 1 } impl ProfileDetails { @@ -80,7 +74,7 @@ impl ProfileDetails { pub fn propic_from_principal(principal: Principal) -> String { let index = index_from_principal(principal); - format!("{GOBGOB_PROPIC_URL}{}/public", index.to_string()) + format!("{GOBGOB_PROPIC_URL}{}/public", index) } #[derive(Clone, Copy)]