mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-07-25 05:40:50 +02:00
refactor: ensure that only profiles without group are shown in the default list
This commit is contained in:
+2
-2
@@ -58,7 +58,7 @@ export default function Home() {
|
|||||||
useState(false);
|
useState(false);
|
||||||
const [groupAssignmentDialogOpen, setGroupAssignmentDialogOpen] =
|
const [groupAssignmentDialogOpen, setGroupAssignmentDialogOpen] =
|
||||||
useState(false);
|
useState(false);
|
||||||
const [selectedGroupId, setSelectedGroupId] = useState<string | null>(null);
|
const [selectedGroupId, setSelectedGroupId] = useState<string>("default");
|
||||||
const [selectedProfilesForGroup, setSelectedProfilesForGroup] = useState<
|
const [selectedProfilesForGroup, setSelectedProfilesForGroup] = useState<
|
||||||
string[]
|
string[]
|
||||||
>([]);
|
>([]);
|
||||||
@@ -82,7 +82,7 @@ export default function Home() {
|
|||||||
const { isMicrophoneAccessGranted, isCameraAccessGranted, isInitialized } =
|
const { isMicrophoneAccessGranted, isCameraAccessGranted, isInitialized } =
|
||||||
usePermissions();
|
usePermissions();
|
||||||
|
|
||||||
const handleSelectGroup = useCallback((groupId: string | null) => {
|
const handleSelectGroup = useCallback((groupId: string) => {
|
||||||
setSelectedGroupId(groupId);
|
setSelectedGroupId(groupId);
|
||||||
setSelectedProfiles([]);
|
setSelectedProfiles([]);
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { GroupWithCount } from "@/types";
|
|||||||
|
|
||||||
interface GroupBadgesProps {
|
interface GroupBadgesProps {
|
||||||
selectedGroupId: string | null;
|
selectedGroupId: string | null;
|
||||||
onGroupSelect: (groupId: string | null) => void;
|
onGroupSelect: (groupId: string) => void;
|
||||||
refreshTrigger?: number;
|
refreshTrigger?: number;
|
||||||
groups: GroupWithCount[];
|
groups: GroupWithCount[];
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
@@ -39,7 +39,7 @@ export function GroupBadges({
|
|||||||
variant={selectedGroupId === group.id ? "default" : "secondary"}
|
variant={selectedGroupId === group.id ? "default" : "secondary"}
|
||||||
className="cursor-pointer hover:bg-primary/80 transition-colors flex items-center gap-2 px-3 py-1"
|
className="cursor-pointer hover:bg-primary/80 transition-colors flex items-center gap-2 px-3 py-1"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onGroupSelect(selectedGroupId === group.id ? null : group.id);
|
onGroupSelect(selectedGroupId === group.id ? "default" : group.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span>{group.name}</span>
|
<span>{group.name}</span>
|
||||||
|
|||||||
@@ -147,10 +147,10 @@ export function ProfilesDataTable({
|
|||||||
|
|
||||||
// Filter data by selected group
|
// Filter data by selected group
|
||||||
const filteredData = React.useMemo(() => {
|
const filteredData = React.useMemo(() => {
|
||||||
if (!selectedGroupId) return data;
|
if (!selectedGroupId || selectedGroupId === "default") {
|
||||||
if (selectedGroupId === "default") {
|
|
||||||
return data.filter((profile) => !profile.group_id);
|
return data.filter((profile) => !profile.group_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return data.filter((profile) => profile.group_id === selectedGroupId);
|
return data.filter((profile) => profile.group_id === selectedGroupId);
|
||||||
}, [data, selectedGroupId]);
|
}, [data, selectedGroupId]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user