Chats: sort most recently updated chats to the top

loading-indicator-on-tls^2
Alex Gleason 2020-08-26 23:20:16 -05:00
rodzic c4aae14148
commit 29f415d786
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 12 dodań i 1 usunięć

Wyświetl plik

@ -10,7 +10,18 @@ import { makeGetChat } from 'soapbox/selectors';
const mapStateToProps = state => {
const getChat = makeGetChat();
return {
chats: state.get('chats').map(chat => getChat(state, chat.toJS())),
chats: state.get('chats').map(chat =>
getChat(state, chat.toJS())
).sort((valueA, valueB) => {
// Sort most recently updated chats at the top
const a = new Date(valueA.get('updated_at'));
const b = new Date(valueB.get('updated_at'));
if (a === b) return 0;
if (a > b) return -1;
if (a < b) return 1;
return 0;
}),
};
};