add: order dms by last message time
This commit is contained in:
parent
0af95e517d
commit
9443bfb58d
6 changed files with 29 additions and 6 deletions
|
@ -21,6 +21,7 @@ impl DataManager {
|
|||
position: get!(x->6(i32)) as usize,
|
||||
members: serde_json::from_str(&get!(x->7(String))).unwrap(),
|
||||
title: get!(x->8(String)),
|
||||
last_message: get!(x->9(i64)) as usize,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,7 +82,7 @@ impl DataManager {
|
|||
|
||||
let res = query_rows!(
|
||||
&conn,
|
||||
"SELECT * FROM channels WHERE (owner = $1 OR members LIKE $2) AND community = 0 ORDER BY created DESC",
|
||||
"SELECT * FROM channels WHERE (owner = $1 OR members LIKE $2) AND community = 0 ORDER BY last_message DESC",
|
||||
params![&(user as i64), &format!("%{user}%")],
|
||||
|x| { Self::get_channel_from_row(x) }
|
||||
);
|
||||
|
@ -162,7 +163,7 @@ impl DataManager {
|
|||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"INSERT INTO channels VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)",
|
||||
"INSERT INTO channels VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
params![
|
||||
&(data.id as i64),
|
||||
&(data.community as i64),
|
||||
|
@ -172,7 +173,8 @@ impl DataManager {
|
|||
&(data.minimum_role_write as i32),
|
||||
&(data.position as i32),
|
||||
&serde_json::to_string(&data.members).unwrap(),
|
||||
&data.title
|
||||
&data.title,
|
||||
&(data.last_message as i64)
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -320,4 +322,5 @@ impl DataManager {
|
|||
auto_method!(update_channel_minimum_role_read(i32)@get_channel_by_id:MANAGE_CHANNELS -> "UPDATE channels SET minimum_role_read = $1 WHERE id = $2" --cache-key-tmpl="atto.channel:{}");
|
||||
auto_method!(update_channel_minimum_role_write(i32)@get_channel_by_id:MANAGE_CHANNELS -> "UPDATE channels SET minimum_role_write = $1 WHERE id = $2" --cache-key-tmpl="atto.channel:{}");
|
||||
auto_method!(update_channel_members(Vec<usize>)@get_channel_by_id:MANAGE_CHANNELS -> "UPDATE channels SET members = $1 WHERE id = $2" --serde --cache-key-tmpl="atto.channel:{}");
|
||||
auto_method!(update_channel_last_message(i64) -> "UPDATE channels SET last_message = $1 WHERE id = $2" --cache-key-tmpl="atto.channel:{}");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue