Fix table headers and pagination
This commit is contained in:
parent
5443768b5c
commit
6e105a8a41
1 changed files with 14 additions and 6 deletions
|
@ -753,8 +753,12 @@ impl Service {
|
|||
rooms.sort_by_key(|r| r.1);
|
||||
rooms.reverse();
|
||||
|
||||
let slice_start = page.saturating_sub(1) * PAGE_SIZE;
|
||||
let Some(rooms) = rooms.get(slice_start..slice_start + PAGE_SIZE) else {
|
||||
let rooms: Vec<_> = rooms.into_iter()
|
||||
.skip(page.saturating_sub(1) * PAGE_SIZE)
|
||||
.take(PAGE_SIZE)
|
||||
.collect();
|
||||
|
||||
if rooms.is_empty() {
|
||||
return Ok(RoomMessageEventContent::text_plain("No more rooms."));
|
||||
};
|
||||
|
||||
|
@ -767,7 +771,7 @@ impl Service {
|
|||
.join("\n")
|
||||
);
|
||||
let output_html = format!(
|
||||
"<table><caption>Room list - page {page}</caption>\n<tr><th>id</th>\t<th>name</th>\t<th>members</th></tr>\n{}</table>",
|
||||
"<table><caption>Room list - page {page}</caption>\n<tr><th>id</th>\t<th>members</th>\t<th>name</th></tr>\n{}</table>",
|
||||
rooms
|
||||
.iter()
|
||||
.map(|(id, members, name)| format!(
|
||||
|
@ -891,9 +895,13 @@ impl Service {
|
|||
.collect::<Vec<_>>();
|
||||
rooms.sort_by_key(|r| r.1);
|
||||
rooms.reverse();
|
||||
|
||||
let rooms: Vec<_> = rooms.into_iter()
|
||||
.skip(page.saturating_sub(1) * PAGE_SIZE)
|
||||
.take(PAGE_SIZE)
|
||||
.collect();
|
||||
|
||||
let slice_start = page.saturating_sub(1) * PAGE_SIZE;
|
||||
let Some(rooms) = rooms.get(slice_start..slice_start + PAGE_SIZE) else {
|
||||
if rooms.is_empty() {
|
||||
return Ok(RoomMessageEventContent::text_plain("No more rooms."));
|
||||
};
|
||||
|
||||
|
@ -906,7 +914,7 @@ impl Service {
|
|||
.join("\n")
|
||||
);
|
||||
let output_html = format!(
|
||||
"<table><caption>Room directory - page {page}</caption>\n<tr><th>id</th>\t<th>name</th>\t<th>members</th></tr>\n{}</table>",
|
||||
"<table><caption>Room directory - page {page}</caption>\n<tr><th>id</th>\t<th>members</th>\t<th>name</th></tr>\n{}</table>",
|
||||
rooms
|
||||
.iter()
|
||||
.map(|(id, members, name)| format!(
|
||||
|
|
Loading…
Reference in a new issue