[FIX] Omnichannel chat is broken the first time is taken (#4037)
* [FIX] Omnichannel chat is broken the first time is taken * refactor how to get a room from db
This commit is contained in:
parent
0a67cb8096
commit
3c53d48a3e
|
@ -16,7 +16,15 @@ import RoomTypeIcon from '../../containers/RoomTypeIcon';
|
||||||
import SafeAreaView from '../../containers/SafeAreaView';
|
import SafeAreaView from '../../containers/SafeAreaView';
|
||||||
import Status from '../../containers/Status';
|
import Status from '../../containers/Status';
|
||||||
import StatusBar from '../../containers/StatusBar';
|
import StatusBar from '../../containers/StatusBar';
|
||||||
import { IApplicationState, IBaseScreen, IRoom, ISubscription, IUser, TSubscriptionModel } from '../../definitions';
|
import {
|
||||||
|
IApplicationState,
|
||||||
|
IBaseScreen,
|
||||||
|
IRoom,
|
||||||
|
ISubscription,
|
||||||
|
IUser,
|
||||||
|
SubscriptionType,
|
||||||
|
TSubscriptionModel
|
||||||
|
} from '../../definitions';
|
||||||
import { withDimensions } from '../../dimensions';
|
import { withDimensions } from '../../dimensions';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import database from '../../lib/database';
|
import database from '../../lib/database';
|
||||||
|
@ -33,6 +41,7 @@ import styles from './styles';
|
||||||
import { ERoomType } from '../../definitions/ERoomType';
|
import { ERoomType } from '../../definitions/ERoomType';
|
||||||
import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
|
import { E2E_ROOM_TYPES, SWITCH_TRACK_COLOR, themes } from '../../lib/constants';
|
||||||
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
|
import { compareServerVersion } from '../../lib/methods/helpers/compareServerVersion';
|
||||||
|
import { getSubscriptionByRoomId } from '../../lib/database/services/Subscription';
|
||||||
|
|
||||||
interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> {
|
interface IRoomActionsViewProps extends IBaseScreen<ChatsStackParamList, 'RoomActionsView'> {
|
||||||
userId: string;
|
userId: string;
|
||||||
|
@ -139,15 +148,24 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
const { room, member } = this.state;
|
const { room, member } = this.state;
|
||||||
if (room.rid) {
|
if (room.rid) {
|
||||||
if (!room.id && !this.isOmnichannelPreview) {
|
if (!room.id) {
|
||||||
try {
|
if (room.t === SubscriptionType.OMNICHANNEL) {
|
||||||
const result = await RocketChat.getChannelInfo(room.rid);
|
if (!this.isOmnichannelPreview) {
|
||||||
if (result.success) {
|
const result = await getSubscriptionByRoomId(room.rid);
|
||||||
// @ts-ignore
|
if (result) {
|
||||||
this.setState({ room: { ...result.channel, rid: result.channel._id } });
|
this.setState({ room: result });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const result = await RocketChat.getChannelInfo(room.rid);
|
||||||
|
if (result.success) {
|
||||||
|
// @ts-ignore
|
||||||
|
this.setState({ room: { ...result.channel, rid: result.channel._id } });
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log(e);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue