Compare commits

...

1 Commits

Author SHA1 Message Date
Reinaldo Neto 0cdcd77e5d [TEMP] Room actions not working in search view 2022-06-07 16:34:25 -03:00
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);
@ -28,18 +28,7 @@ export const localSearch = async ({ text = '', filterUsers = true, filterRooms =
const sliceSubscriptions = subscriptions.slice(0, 7); const sliceSubscriptions = subscriptions.slice(0, 7);
const search = sliceSubscriptions.map(sub => ({ return sliceSubscriptions;
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;
}; };
export const search = async ({ text = '', filterUsers = true, filterRooms = true }): Promise<(ISearch | ISearchLocal)[]> => { export const search = async ({ text = '', filterUsers = true, filterRooms = true }): Promise<(ISearch | ISearchLocal)[]> => {

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