Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groups: make sure segmented groups are filtered from the main list on mobile #3220

Merged
merged 2 commits into from
Feb 8, 2024
Merged
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
4 changes: 3 additions & 1 deletion ui/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ export default function Sidebar() {
const flagsToFilter = useMemo(() => {
const flags = new Set();
Object.entries(pinnedGroups).forEach(([flag]) => flags.add(flag));
Object.entries(invitedGroups).forEach(([flag]) => flags.add(flag));
loadingGroups.forEach(([flag]) => flags.add(flag));
newGroups?.forEach(([flag]) => flags.add(flag));
gangsWithClaims.forEach((flag) => flags.add(flag));
return flags;
}, [pinnedGroups, loadingGroups, newGroups]);
}, [pinnedGroups, loadingGroups, newGroups, gangsWithClaims, invitedGroups]);

const allOtherGroups = useMemo(
() => sortedGroups.filter(([flag, _g]) => !flagsToFilter.has(flag)),
Expand Down
18 changes: 17 additions & 1 deletion ui/src/nav/MobileRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ export default function MobileRoot() {
const hasNewGroups = !!newGroups.length;
const hasPendingGangs = Object.keys(pendingGangs).length > 0;

// get all non-segmented groups
const flagsToFilter = useMemo(() => {
const flags = new Set();
Object.entries(pinnedGroups).forEach(([flag]) => flags.add(flag));
Object.entries(pendingGangs).forEach(([flag]) => flags.add(flag));
loadingGroups.forEach(([flag]) => flags.add(flag));
newGroups?.forEach(([flag]) => flags.add(flag));
gangsWithClaims.forEach((flag) => flags.add(flag));
return flags;
}, [pinnedGroups, loadingGroups, newGroups, gangsWithClaims, pendingGangs]);

const allOtherGroups = useMemo(
() => sortedGroups.filter(([flag, _g]) => !flagsToFilter.has(flag)),
[sortedGroups, flagsToFilter]
);

return (
<Layout
className="flex-1 bg-white"
Expand Down Expand Up @@ -92,7 +108,7 @@ export default function MobileRoot() {
</div>
) : (
<GroupsScrollingContext.Provider value={isScrolling}>
<GroupList groups={sortedGroups} isScrolling={scroll.current}>
<GroupList groups={allOtherGroups} isScrolling={scroll.current}>
{hasPinnedGroups ||
hasPendingGangs ||
hasGangsWithClaims ||
Expand Down
Loading