From 29fe20af090a54102319602b9946600eeeaf9e8e Mon Sep 17 00:00:00 2001 From: zhom <2717306+zhom@users.noreply.github.com> Date: Sat, 16 Aug 2025 12:33:54 +0400 Subject: [PATCH] refactor: move profile filtering outside table component --- src/app/page.tsx | 13 +- src/components/profile-data-table.tsx | 265 ++++++++++++-------------- 2 files changed, 133 insertions(+), 145 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 4376461..8b1fc2c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -3,7 +3,7 @@ import { invoke } from "@tauri-apps/api/core"; import { listen } from "@tauri-apps/api/event"; import { getCurrent } from "@tauri-apps/plugin-deep-link"; -import { useCallback, useEffect, useRef, useState } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { CamoufoxConfigDialog } from "@/components/camoufox-config-dialog"; import { CreateProfileDialog } from "@/components/create-profile-dialog"; import { DeleteConfirmationDialog } from "@/components/delete-confirmation-dialog"; @@ -764,6 +764,15 @@ export default function Home() { } }, [isInitialized, checkAllPermissions]); + // Filter data by selected group + const filteredProfiles = useMemo(() => { + if (!selectedGroupId || selectedGroupId === "default") { + return profiles.filter((profile) => !profile.group_id); + } + + return profiles.filter((profile) => profile.group_id === selectedGroupId); + }, [profiles, selectedGroupId]); + return (