This commit is contained in:
Christian Fehmer 2025-07-18 22:36:55 +02:00 committed by Christian Fehmer
parent cf0962f8bf
commit 6b118663d1
2 changed files with 17 additions and 7 deletions

View file

@ -17,6 +17,8 @@ import { SortedTable } from "../utils/sorted-table";
const pageElement = $(".page.pageFriends");
let friendsTable: SortedTable<Friend> | undefined = undefined;
const addFriendModal = new SimpleModal({
id: "addFriend",
title: "Add a friend",
@ -103,12 +105,17 @@ async function fetchFriends(): Promise<void> {
$(".pageFriends .friends table").removeClass("hidden");
$(".pageFriends .friends .nodata").addClass("hidden");
new SortedTable<Friend>({
table: ".pageFriends .friends table",
data: result.body.data,
buildRow: buildFriendRow,
initialSort: { property: "name", descending: false },
});
if (friendsTable === undefined) {
friendsTable = new SortedTable<Friend>({
table: ".pageFriends .friends table",
data: result.body.data,
buildRow: buildFriendRow,
initialSort: { property: "name", descending: false },
});
} else {
friendsTable.setData(result.body.data);
}
friendsTable.updateBody();
}
}

View file

@ -1,4 +1,7 @@
type Sort = { property: string; descending: boolean };
type Sort = {
property: string;
descending: boolean;
};
type SortedTableOptions<T> = {
table: string;