[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:
parent
28ee43f817
commit
a5a45f533b
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue