From a5a45f533bb11f0f80fe0735b98290cc9b1c9648 Mon Sep 17 00:00:00 2001 From: Danish Ahmed Mirza <77742477+try-catch-stack@users.noreply.github.com> Date: Wed, 22 Jun 2022 01:05:51 +0530 Subject: [PATCH] [FIX] Rooms are losing the time after search (#3722) Co-authored-by: Reinaldo Neto Co-authored-by: Diego Mello --- app/lib/methods/search.ts | 17 +++-------------- .../CreateDiscussionView/SelectChannel.tsx | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-) 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