[FIX] Rooms are losing the time after search (#3722)

Co-authored-by: Reinaldo Neto <reinaldonetof@hotmail.com>
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Danish Ahmed Mirza 2022-06-22 01:05:51 +05:30 committed by GitHub
parent 28ee43f817
commit a5a45f533b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 15 deletions

View File

@ -3,12 +3,12 @@ import { Q } from '@nozbe/watermelondb';
import { sanitizeLikeString } from '../database/utils'; import { sanitizeLikeString } from '../database/utils';
import database from '../database/index'; import database from '../database/index';
import { spotlight } from '../services/restApi'; import { spotlight } from '../services/restApi';
import { ISearch, ISearchLocal, SubscriptionType } from '../../definitions'; import { ISearch, ISearchLocal, SubscriptionType, TSubscriptionModel } from '../../definitions';
import { isGroupChat } from './helpers'; import { isGroupChat } from './helpers';
let debounce: null | ((reason: string) => void) = null; 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<TSubscriptionModel[]> => {
const searchText = text.trim(); const searchText = text.trim();
const db = database.active; const db = database.active;
const likeString = sanitizeLikeString(searchText); 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)); subscriptions = subscriptions.filter(item => item.t !== 'd' || isGroupChat(item));
} }
const sliceSubscriptions = subscriptions.slice(0, 7); const search = 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)[];
return search; return search;
}; };

View File

@ -25,7 +25,7 @@ const SelectChannel = ({
const getChannels = debounce(async (keyword = '') => { const getChannels = debounce(async (keyword = '') => {
try { try {
const res = await localSearch({ text: keyword }); const res = (await localSearch({ text: keyword })) as ISearchLocal[];
setChannels(res); setChannels(res);
} catch { } catch {
// do nothing // do nothing