mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 06:16:30 +03:00
refactor: order self addresses by addition timestamp
This way the order does not change when primary address is changed.
This commit is contained in:
@@ -944,12 +944,18 @@ impl Context {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the primary self address followed by all secondary ones.
|
/// Returns all self addresses, newest first.
|
||||||
pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>> {
|
pub(crate) async fn get_all_self_addrs(&self) -> Result<Vec<String>> {
|
||||||
let primary_addrs = self.get_config(Config::ConfiguredAddr).await?.into_iter();
|
self.sql
|
||||||
let secondary_addrs = self.get_secondary_self_addrs().await?.into_iter();
|
.query_map_vec(
|
||||||
|
"SELECT addr FROM transports ORDER BY add_timestamp DESC",
|
||||||
Ok(primary_addrs.chain(secondary_addrs).collect())
|
(),
|
||||||
|
|row| {
|
||||||
|
let addr: String = row.get(0)?;
|
||||||
|
Ok(addr)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all secondary self addresses.
|
/// Returns all secondary self addresses.
|
||||||
|
|||||||
Reference in New Issue
Block a user