Skip to content

Commit 4d21c60

Browse files
committed
fix(notification): sort repositories by notification's last update time
1 parent 5634431 commit 4d21c60

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/notifications/screens/notifications.screen.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,17 @@ class Notifications extends Component {
236236
}
237237

238238
getSortedRepos = () => {
239-
const repositories = [
240-
...new Set(
241-
this.notifications().map(
242-
notification => notification.repository.full_name
243-
)
244-
),
245-
];
246-
247-
return repositories.sort((a, b) => {
248-
return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
239+
const updateTimeMap = {};
240+
241+
this.notifications().forEach(notification => {
242+
const repoName = notification.repository.full_name;
243+
244+
updateTimeMap[repoName] =
245+
updateTimeMap[repoName] || notification.update_time;
246+
});
247+
248+
return Object.keys(updateTimeMap).sort((a, b) => {
249+
return new Date(a) - new Date(b);
249250
});
250251
};
251252

0 commit comments

Comments
 (0)