From e10de8b209a2f7ff368cf30c0978c918e34b9021 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Thu, 22 Sep 2022 22:39:52 -0300 Subject: [PATCH] [FIX] Search in Rooms List crashes Android app (#4546) * [FIX] Search in Rooms List crashes Android app * back to previous search * change the method/searchlocal --- app/lib/methods/search.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/lib/methods/search.ts b/app/lib/methods/search.ts index 6830b7942..7d144c933 100644 --- a/app/lib/methods/search.ts +++ b/app/lib/methods/search.ts @@ -3,12 +3,12 @@ import { Q } from '@nozbe/watermelondb'; import { sanitizeLikeString } from '../database/utils'; import database from '../database/index'; import { spotlight } from '../services/restApi'; -import { ISearch, ISearchLocal, SubscriptionType, TSubscriptionModel } from '../../definitions'; +import { ISearch, ISearchLocal, SubscriptionType } from '../../definitions'; import { isGroupChat } from './helpers'; let debounce: null | ((reason: string) => void) = null; -export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise => { +export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise => { const searchText = text.trim(); const db = database.active; const likeString = sanitizeLikeString(searchText); @@ -26,7 +26,20 @@ export const localSearch = async ({ text = '', filterUsers = true, filterRooms = subscriptions = subscriptions.filter(item => item.t !== 'd' || isGroupChat(item)); } - const search = subscriptions.slice(0, 7); + const search = subscriptions.slice(0, 7).map(item => ({ + avatarETag: item.avatarETag, + rid: item.rid, + name: item.name, + t: item.t, + fname: item.fname, + encrypted: item.encrypted, + lastMessage: item.lastMessage, + _id: item._id, + status: item.status, + username: item.usernames, + outside: false, + search: true + })) as ISearchLocal[]; return search; };