From 201966102efc0368d5347d3d764a45527efe1f1c Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Tue, 13 Feb 2024 15:36:04 +0700 Subject: [PATCH] Only show spaces in sidebar which are in `pageListIds` - Only a small condition change. The other changes are simply JS cleanups --- .../components/AnnotationsSidebar.tsx | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx b/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx index 854d4d70e9..73ad8f1c1c 100644 --- a/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx +++ b/src/sidebar/annotations-sidebar/components/AnnotationsSidebar.tsx @@ -1390,12 +1390,12 @@ export class AnnotationsSidebar extends React.Component< : undefined const allLists = normalizedStateToArray(lists).filter( (listData) => - listData.unifiedAnnotationIds?.length > 0 || - listData.hasRemoteAnnotationsToLoad || - (listData.type === 'page-link' && - listData.normalizedPageUrl === normalizedPageUrl) || - pageListIds.has(listData.unifiedId) || - pageActiveListIds.includes(listData.unifiedId), + pageListIds.has(listData.unifiedId) && + (listData.unifiedAnnotationIds?.length > 0 || + listData.hasRemoteAnnotationsToLoad || + (listData.type === 'page-link' && + listData.normalizedPageUrl === normalizedPageUrl) || + pageActiveListIds.includes(listData.unifiedId)), ) if (allLists?.length === 0) { @@ -1429,9 +1429,9 @@ export class AnnotationsSidebar extends React.Component< Page Links{' '} - {pageLinkLists?.length} + {pageLinkLists.length} - {pageLinkLists?.length > 0 && ( + {pageLinkLists.length > 0 && ( {pageLinkLists.map((listData) => { this.maybeCreateContextBtnRef(listData) @@ -1448,9 +1448,9 @@ export class AnnotationsSidebar extends React.Component< My Spaces{' '} - {myLists?.length} + {myLists.length} - {myLists?.length > 0 ? ( + {myLists.length > 0 && ( {myLists.map((listData) => { this.maybeCreateContextBtnRef(listData) @@ -1461,15 +1461,15 @@ export class AnnotationsSidebar extends React.Component< ) })} - ) : undefined} + )} Followed Spaces{' '} - {followedLists?.length} + {followedLists.length} - {followedLists?.length > 0 ? ( + {followedLists.length > 0 && ( {followedLists.map((listData) => this.renderSpacesItem( @@ -1478,15 +1478,15 @@ export class AnnotationsSidebar extends React.Component< ), )} - ) : undefined} + )} Joined Spaces{' '} - {joinedLists?.length} + {joinedLists.length} - {joinedLists?.length > 0 ? ( + {joinedLists.length > 0 && ( {joinedLists.map((listData) => this.renderSpacesItem( @@ -1495,7 +1495,7 @@ export class AnnotationsSidebar extends React.Component< ), )} - ) : undefined} + )} ) @@ -3459,9 +3459,8 @@ export class AnnotationsSidebar extends React.Component< ), )} - {this.props.activeTab === 'spaces' && ( - <>{this.renderSharedNotesByList()} - )} + {this.props.activeTab === 'spaces' && + this.renderSharedNotesByList()} )} 1000 - props.zIndex};