Skip to content

Commit

Permalink
Merge pull request #2310 from daostack/bugfix/CW-2183-commons-sorting
Browse files Browse the repository at this point in the history
Sort commons by lastActivity in the dropdowns - Fix commons sorting #2183
  • Loading branch information
andreymikhadyuk authored Nov 13, 2023
2 parents 6bf4216 + 0d24349 commit 5f5f58c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ export const useMenuItems = (options: Options): MenuItem[] => {
onCommonClick(stateItem.commonId);
},
}))
.sort((item) => (item.id === activeStateItemId ? -1 : 1))
.sort((prevItem, nextItem) => {
if (prevItem.id === activeStateItemId) {
return -1;
}
if (nextItem.id === activeStateItemId) {
return 1;
}

return 0;
})
.concat({
id: CREATE_COMMON_ITEM_ID,
text: "Create a common",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ const FeedBreadcrumbsItem: FC<FeedBreadcrumbsItemProps> = (props) => {
() =>
baseItems.length === 0
? [activeItem]
: [...baseItems].sort((prevItem) =>
prevItem.commonId === activeItem.commonId ? -1 : 1,
),
: [...baseItems].sort((prevItem, nextItem) => {
if (prevItem.commonId === activeItem.commonId) {
return -1;
}
if (nextItem.commonId === activeItem.commonId) {
return 1;
}

return 0;
}),
[baseItems, activeItem],
);

Expand Down

0 comments on commit 5f5f58c

Please sign in to comment.