diff --git a/ts/test-both/util/filterAndSortConversations_test.ts b/ts/test-both/util/filterAndSortConversations_test.ts index 519d0c652..104a8c99f 100644 --- a/ts/test-both/util/filterAndSortConversations_test.ts +++ b/ts/test-both/util/filterAndSortConversations_test.ts @@ -28,6 +28,9 @@ describe('filterAndSortConversationsByRecent', () => { e164: '+16505559876', activeAt: 2, }), + getDefaultConversation({ + title: 'A long title ending with burrito', + }), ]; it('sorts by recency when no search term is provided', () => { @@ -42,6 +45,16 @@ describe('filterAndSortConversationsByRecent', () => { 'Boxing Club', 'Abraham Lincoln', 'Not recent', + 'A long title ending with burrito', ]); }); + + it('finds a conversation when the search term is at the end of a long title', () => { + const titles = filterAndSortConversationsByRecent( + conversations, + 'burrito', + 'US' + ).map(convo => convo.title); + assert.deepEqual(titles, ['A long title ending with burrito']); + }); }); diff --git a/ts/util/filterAndSortConversations.ts b/ts/util/filterAndSortConversations.ts index d38f24cb3..6f3919b78 100644 --- a/ts/util/filterAndSortConversations.ts +++ b/ts/util/filterAndSortConversations.ts @@ -19,6 +19,9 @@ const FUSE_OPTIONS: Fuse.IFuseOptions = { useExtendedSearch: true, // We sort manually anyway shouldSort: true, + // the default of 100 is not enough to catch a word at the end of a convo/group title + // 150 is about right + distance: 150, keys: [ { name: 'searchableTitle',