Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions components/CategoryFilterWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ import { UsersIcon } from '@heroicons/react/24/outline';
export const CategoryFilterWidget: React.FC = () => {
const { shortcuts, filterCategory, setFilterCategory, filterProfile, setFilterProfile } = useGTab();

const activeCategories = useMemo(() => {
return ['All', ...new Set(shortcuts.map(s => s.category))];
}, [shortcuts]);
const { activeCategories, uniqueProfiles } = useMemo(() => {
const categoriesSet = new Set<string>();
const profilesSet = new Set<string>();

for (const s of shortcuts) {
if (s.category) categoriesSet.add(s.category);
if (s.profiles) {
for (const p of s.profiles) {
if (p.name) profilesSet.add(p.name);
}
}
}

const uniqueProfiles = useMemo(() => {
return Array.from(new Set(shortcuts.flatMap(s => s.profiles?.map(p => p.name) || []))).sort();
return {
activeCategories: ['All', ...categoriesSet],
uniqueProfiles: Array.from(profilesSet).sort()
};
}, [shortcuts]);

return (
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading