This commit is contained in:
2026-09-30 17:43:47 +07:00
parent eda8eb543d
commit 41e48de4fd
-18
View File
@@ -46,11 +46,8 @@ setting_accessors! {
pub nip4e: bool, pub nip4e: bool,
pub trusted_relays: Vec<String>, pub trusted_relays: Vec<String>,
pub file_server: Url, pub file_server: Url,
pub recent_communities: Vec<String>,
} }
const RECENT_COMMUNITIES_CAP: usize = 10;
/// Signer kind /// Signer kind
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum SignerKind { pub enum SignerKind {
@@ -133,10 +130,6 @@ pub struct Settings {
/// Server for blossom media attachments /// Server for blossom media attachments
pub file_server: Url, pub file_server: Url,
/// Recently opened community ids, newest first
#[serde(default)]
pub recent_communities: Vec<String>,
} }
impl Default for Settings { impl Default for Settings {
@@ -149,7 +142,6 @@ impl Default for Settings {
nip4e: false, nip4e: false,
trusted_relays: vec![], trusted_relays: vec![],
file_server: Url::parse(DEFAULT_FILE_SERVER).unwrap(), file_server: Url::parse(DEFAULT_FILE_SERVER).unwrap(),
recent_communities: vec![],
} }
} }
} }
@@ -332,14 +324,4 @@ impl AppSettings {
} }
}); });
} }
/// Move a community to the front of the recently opened list
pub fn record_recent_community(&mut self, id: String, cx: &mut Context<Self>) {
self.inner.update(cx, |this, cx| {
this.recent_communities.retain(|existing| existing != &id);
this.recent_communities.insert(0, id);
this.recent_communities.truncate(RECENT_COMMUNITIES_CAP);
cx.notify();
});
}
} }