mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Second Thought.. We should useMemo same as we do for the other data to prevent unnecessary compute.
This commit is contained in:
parent
3c9afeddd7
commit
5a32a5151a
1 changed files with 13 additions and 4 deletions
|
|
@ -141,6 +141,15 @@ const UsersTable = () => {
|
|||
/**
|
||||
* useMemo
|
||||
*/
|
||||
// Create a profile ID to name lookup map for efficient rendering
|
||||
const profileIdToName = useMemo(() => {
|
||||
const map = {};
|
||||
Object.values(profiles).forEach((profile) => {
|
||||
map[profile.id] = profile.name;
|
||||
});
|
||||
return map;
|
||||
}, [profiles]);
|
||||
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
{
|
||||
|
|
@ -268,9 +277,9 @@ const UsersTable = () => {
|
|||
grow: true,
|
||||
cell: ({ getValue }) => {
|
||||
const userProfiles = getValue() || [];
|
||||
const profileNames = Object.values(profiles)
|
||||
.filter((profile) => userProfiles.includes(profile.id))
|
||||
.map((profile) => profile.name);
|
||||
const profileNames = userProfiles
|
||||
.map((id) => profileIdToName[id])
|
||||
.filter(Boolean); // Filter out any undefined values
|
||||
return (
|
||||
<Group gap={4} wrap="wrap" py={4}>
|
||||
{profileNames.length > 0 ? (
|
||||
|
|
@ -308,7 +317,7 @@ const UsersTable = () => {
|
|||
),
|
||||
},
|
||||
],
|
||||
[theme, editUser, deleteUser, visiblePasswords, togglePasswordVisibility]
|
||||
[theme, editUser, deleteUser, visiblePasswords, togglePasswordVisibility, profileIdToName]
|
||||
);
|
||||
|
||||
const closeUserForm = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue