Improve performance of _getLeftPaneList (#3398)
* Improve efficiency of conversation sorting in getLeftPaneLists - Sort conversations and archivedConversations separately, without items that had falsey activeAt - Don't convert conversation titles to lowercase before comparing: collator.compare() is case-insensitive anyway. * Enable caching for format() in PhoneNumber
This commit is contained in:
parent
9376dba806
commit
6150c3dcc0
2 changed files with 18 additions and 8 deletions
|
@ -91,11 +91,11 @@ export const _getConversationComparator = (
|
|||
const leftTitle = getConversationTitle(left, {
|
||||
i18n,
|
||||
ourRegionCode,
|
||||
}).toLowerCase();
|
||||
});
|
||||
const rightTitle = getConversationTitle(right, {
|
||||
i18n,
|
||||
ourRegionCode,
|
||||
}).toLowerCase();
|
||||
});
|
||||
|
||||
return collator.compare(leftTitle, rightTitle);
|
||||
};
|
||||
|
@ -114,15 +114,13 @@ export const _getLeftPaneLists = (
|
|||
conversations: Array<ConversationType>;
|
||||
archivedConversations: Array<ConversationType>;
|
||||
} => {
|
||||
const values = Object.values(lookup);
|
||||
const sorted = values.sort(comparator);
|
||||
|
||||
const conversations: Array<ConversationType> = [];
|
||||
const archivedConversations: Array<ConversationType> = [];
|
||||
|
||||
const max = sorted.length;
|
||||
const values = Object.values(lookup);
|
||||
const max = values.length;
|
||||
for (let i = 0; i < max; i += 1) {
|
||||
let conversation = sorted[i];
|
||||
let conversation = values[i];
|
||||
if (!conversation.activeAt) {
|
||||
continue;
|
||||
}
|
||||
|
@ -141,6 +139,9 @@ export const _getLeftPaneLists = (
|
|||
}
|
||||
}
|
||||
|
||||
conversations.sort(comparator);
|
||||
archivedConversations.sort(comparator);
|
||||
|
||||
return { conversations, archivedConversations };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue