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; };