Skip to content

Commit c1c6f43

Browse files
committed
sort 'new' apps to the end of the list
1 parent 7541f78 commit c1c6f43

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/components/MainNav/AppOrderProvider.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,17 @@ export const AppOrderProvider = ({ children }) => { // eslint-disable-line react
151151

152152
// sort the platformApps according to the preference.
153153
navList = platformApps.sort((a, b) => {
154-
return orderedApps.findIndex(({ name }) => a.name === name) -
155-
orderedApps.findIndex(({ name }) => b.name === name);
154+
const aIndex = orderedApps.findIndex(({ name }) => a.name === name);
155+
const bIndex = orderedApps.findIndex(({ name }) => b.name === name);
156+
157+
if (bIndex === -1) {
158+
return -1;
159+
}
160+
161+
if (aIndex === -1) {
162+
return 1;
163+
}
164+
return aIndex - bIndex;
156165
});
157166

158167
// find the apps from the platform that are not saved in user-reordered list and tack them on at the end.

0 commit comments

Comments
 (0)