fix: crashing the app - Cannot read property 'find' of null at fetchRole method (#5447)
* fix: crashing the app - Cannot read property 'find' of null at fetchRole method * minor tweak * minor tweak
This commit is contained in:
parent
35cb39a2f2
commit
9109b87269
|
@ -1,7 +1,7 @@
|
|||
import { Q } from '@nozbe/watermelondb';
|
||||
|
||||
import { LISTENER } from '../../containers/Toast';
|
||||
import { IUser, SubscriptionType, TSubscriptionModel, TUserModel } from '../../definitions';
|
||||
import { IGetRoomRoles, IUser, SubscriptionType, TSubscriptionModel, TUserModel } from '../../definitions';
|
||||
import I18n from '../../i18n';
|
||||
import { getRoomTitle, showConfirmationAlert, showErrorAlert } from '../../lib/methods/helpers';
|
||||
import EventEmitter from '../../lib/methods/helpers/events';
|
||||
|
@ -18,9 +18,9 @@ const handleGoRoom = (item: TGoRoomItem, isMasterDetail: boolean): void => {
|
|||
goRoom({ item, isMasterDetail, popToRoot: true });
|
||||
};
|
||||
|
||||
export const fetchRole = (role: string, selectedUser: TUserModel, roomRoles: any): boolean => {
|
||||
const userRoleResult = roomRoles.find((r: any) => r.u._id === selectedUser._id);
|
||||
return userRoleResult?.roles.includes(role);
|
||||
export const fetchRole = (role: string, selectedUser: TUserModel, roomRoles?: IGetRoomRoles[]): boolean => {
|
||||
const userRoleResult = roomRoles?.find((r: any) => r.u._id === selectedUser._id);
|
||||
return !!userRoleResult?.roles.includes(role);
|
||||
};
|
||||
|
||||
export const fetchRoomMembersRoles = async (roomType: TRoomType, rid: string, updateState: any): Promise<void> => {
|
||||
|
|
|
@ -13,7 +13,7 @@ import SafeAreaView from '../../containers/SafeAreaView';
|
|||
import SearchBox from '../../containers/SearchBox';
|
||||
import StatusBar from '../../containers/StatusBar';
|
||||
import UserItem from '../../containers/UserItem';
|
||||
import { TSubscriptionModel, TUserModel } from '../../definitions';
|
||||
import { IGetRoomRoles, TSubscriptionModel, TUserModel } from '../../definitions';
|
||||
import I18n from '../../i18n';
|
||||
import { useAppSelector, usePermissions } from '../../lib/hooks';
|
||||
import { compareServerVersion, getRoomTitle, isGroupChat } from '../../lib/methods/helpers';
|
||||
|
@ -50,7 +50,7 @@ interface IRoomMembersViewState {
|
|||
members: TUserModel[];
|
||||
room: TSubscriptionModel;
|
||||
end: boolean;
|
||||
roomRoles: any;
|
||||
roomRoles?: IGetRoomRoles[];
|
||||
filter: string;
|
||||
page: number;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ const RoomMembersView = (): React.ReactElement => {
|
|||
members: [],
|
||||
room: params.room || ({} as TSubscriptionModel),
|
||||
end: false,
|
||||
roomRoles: null,
|
||||
roomRoles: undefined,
|
||||
filter: '',
|
||||
page: 0
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue