[FIX] Search in Rooms List crashes Android app (#4546)
* [FIX] Search in Rooms List crashes Android app * back to previous search * change the method/searchlocal
This commit is contained in:
parent
27af3bf5eb
commit
2e24b02dda
|
@ -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, TSubscriptionModel } from '../../definitions';
|
||||
import { ISearch, ISearchLocal, SubscriptionType } from '../../definitions';
|
||||
import { isGroupChat } from './helpers';
|
||||
|
||||
let debounce: null | ((reason: string) => void) = null;
|
||||
|
||||
export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise<TSubscriptionModel[]> => {
|
||||
export const localSearch = async ({ text = '', filterUsers = true, filterRooms = true }): Promise<ISearchLocal[]> => {
|
||||
const searchText = text.trim();
|
||||
const db = database.active;
|
||||
const likeString = sanitizeLikeString(searchText);
|
||||
|
@ -26,7 +26,20 @@ export const localSearch = async ({ text = '', filterUsers = true, filterRooms =
|
|||
subscriptions = subscriptions.filter(item => item.t !== 'd' || isGroupChat(item));
|
||||
}
|
||||
|
||||
const search = subscriptions.slice(0, 7);
|
||||
const search = subscriptions.slice(0, 7).map(item => ({
|
||||
avatarETag: item.avatarETag,
|
||||
rid: item.rid,
|
||||
name: item.name,
|
||||
t: item.t,
|
||||
fname: item.fname,
|
||||
encrypted: item.encrypted,
|
||||
lastMessage: item.lastMessage,
|
||||
_id: item._id,
|
||||
status: item.status,
|
||||
username: item.usernames,
|
||||
outside: false,
|
||||
search: true
|
||||
})) as ISearchLocal[];
|
||||
|
||||
return search;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue