diff --git a/app/lib/methods/search.ts b/app/lib/methods/search.ts index d8f0f7d1a..6830b7942 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 } from '../../definitions'; +import { ISearch, ISearchLocal, SubscriptionType, TSubscriptionModel } from '../../definitions'; import { isGroupChat } from './helpers'; let debounce: null | ((reason: string) => void) = null; -export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise<(ISearch | ISearchLocal)[]> => { +export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise => { const searchText = text.trim(); const db = database.active; const likeString = sanitizeLikeString(searchText); @@ -26,18 +26,7 @@ export const localSearch = async ({ text = '', filterUsers = true, filterRooms = subscriptions = subscriptions.filter(item => item.t !== 'd' || isGroupChat(item)); } - const sliceSubscriptions = subscriptions.slice(0, 7); - - const search = sliceSubscriptions.map(sub => ({ - rid: sub.rid, - name: sub.name, - fname: sub?.fname || '', - avatarETag: sub?.avatarETag || '', - t: sub.t, - encrypted: sub?.encrypted || null, - lastMessage: sub.lastMessage, - ...(sub.teamId && { teamId: sub.teamId }) - })) as (ISearch | ISearchLocal)[]; + const search = subscriptions.slice(0, 7); return search; }; diff --git a/app/views/CreateDiscussionView/SelectChannel.tsx b/app/views/CreateDiscussionView/SelectChannel.tsx index 5e09af9a6..ffca22c08 100644 --- a/app/views/CreateDiscussionView/SelectChannel.tsx +++ b/app/views/CreateDiscussionView/SelectChannel.tsx @@ -25,7 +25,7 @@ const SelectChannel = ({ const getChannels = debounce(async (keyword = '') => { try { - const res = await localSearch({ text: keyword }); + const res = (await localSearch({ text: keyword })) as ISearchLocal[]; setChannels(res); } catch { // do nothing