fix,feat: mention behavior and page titles
This commit is contained in:
parent
7e2f5d0a18
commit
79a054ab40
22 changed files with 314 additions and 140 deletions
|
|
@ -74,7 +74,7 @@ impl MentionHost<'_> {
|
|||
}
|
||||
|
||||
impl Switchboard {
|
||||
pub async fn new(pool: &SqlitePool) -> Result<Self, AppError> {
|
||||
pub async fn gen_trie(pool: &SqlitePool) -> Result<radix_trie::Trie<String,String>, AppError> {
|
||||
let mut trie = radix_trie::Trie::new();
|
||||
|
||||
let mentionables = sqlx::query_as!(
|
||||
|
|
@ -92,9 +92,23 @@ impl Switchboard {
|
|||
trie.insert(mentionable.text, mentionable.uri);
|
||||
}
|
||||
|
||||
Ok(trie)
|
||||
}
|
||||
|
||||
pub async fn new(pool: &SqlitePool) -> Result<Self, AppError> {
|
||||
let trie = Self::gen_trie(pool).await?;
|
||||
Ok(Switchboard { trie })
|
||||
}
|
||||
|
||||
pub fn check_and_assign(self: &mut Self, trie: radix_trie::Trie<String, String>) -> bool {
|
||||
if trie != self.trie {
|
||||
self.trie = trie;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove(self: &mut Self, text: &String) {
|
||||
self.trie.remove(text);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue