Various fixes for message forwarding

This commit is contained in:
Josh Perez 2021-04-28 13:44:48 -07:00 committed by GitHub
parent 3face767aa
commit 353becffac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 222 additions and 44 deletions

View file

@ -32,14 +32,38 @@ const FUSE_OPTIONS: FuseOptions<ConversationType> = {
const collator = new Intl.Collator();
export function filterAndSortConversations(
function searchConversations(
conversations: ReadonlyArray<ConversationType>,
searchTerm: string
): Array<ConversationType> {
return new Fuse<ConversationType>(conversations, FUSE_OPTIONS).search(
searchTerm
);
}
export function filterAndSortConversationsByRecent(
conversations: ReadonlyArray<ConversationType>,
searchTerm: string
): Array<ConversationType> {
if (searchTerm.length) {
return new Fuse<ConversationType>(conversations, FUSE_OPTIONS).search(
searchTerm
);
return searchConversations(conversations, searchTerm);
}
return conversations.concat().sort((a, b) => {
if (a.activeAt && b.activeAt) {
return a.activeAt > b.activeAt ? -1 : 1;
}
return a.activeAt && !b.activeAt ? -1 : 1;
});
}
export function filterAndSortConversationsByTitle(
conversations: ReadonlyArray<ConversationType>,
searchTerm: string
): Array<ConversationType> {
if (searchTerm.length) {
return searchConversations(conversations, searchTerm);
}
return conversations.concat().sort((a, b) => {