chore: improve performance (#42)

* use uniform list for rooms list

* move profile cache to outside gpui context

* update comment

* refactor

* refactor

* .

* .

* add avatar component

* .

* refactor

* .
This commit is contained in:
reya
2025-05-27 07:34:22 +07:00
committed by GitHub
parent 45564c7722
commit 0f884f8142
25 changed files with 1087 additions and 1373 deletions

View File

@@ -1,29 +1,29 @@
use global::constants::IMAGE_SERVICE;
use global::constants::IMAGE_RESIZE_SERVICE;
use gpui::SharedString;
use nostr_sdk::prelude::*;
pub trait SharedProfile {
fn shared_avatar(&self) -> SharedString;
fn shared_name(&self) -> SharedString;
pub trait RenderProfile {
fn render_avatar(&self) -> SharedString;
fn render_name(&self) -> SharedString;
}
impl SharedProfile for Profile {
fn shared_avatar(&self) -> SharedString {
impl RenderProfile for Profile {
fn render_avatar(&self) -> SharedString {
self.metadata()
.picture
.as_ref()
.filter(|picture| !picture.is_empty())
.map(|picture| {
format!(
"{}/?url={}&w=100&h=100&fit=cover&mask=circle&n=-1&default=npub1zfss807aer0j26mwp2la0ume0jqde3823rmu97ra6sgyyg956e0s6xw445.blossom.band/c30703b48f511c293a9003be8100cdad37b8798b77a1dc3ec6eb8a20443d5dea.png",
IMAGE_SERVICE, picture
"{}/?url={}&w=100&h=100&fit=cover&mask=circle&default=https://image.nostr.build/c30703b48f511c293a9003be8100cdad37b8798b77a1dc3ec6eb8a20443d5dea.png&n=-1",
IMAGE_RESIZE_SERVICE, picture
)
.into()
})
.unwrap_or_else(|| "brand/avatar.png".into())
}
fn shared_name(&self) -> SharedString {
fn render_name(&self) -> SharedString {
if let Some(display_name) = self.metadata().display_name.as_ref() {
if !display_name.is_empty() {
return display_name.into();