Regression: RoomProvider using wrong types (#22370)

pull/22304/head^2
Guilherme Gazzo 4 years ago committed by GitHub
parent d05d37acda
commit cc1b66b192
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/ui-sidenav/client/roomList.js
  2. 14
      client/views/room/contexts/RoomContext.ts
  3. 6
      client/views/room/providers/RoomProvider.tsx
  4. 2
      definition/ISubscription.ts

@ -141,7 +141,6 @@ const mergeSubRoom = (subscription) => {
lm: 1,
lastMessage: 1,
uids: 1,
v: 1,
streamingOptions: 1,
usernames: 1,
topic: 1,
@ -156,11 +155,20 @@ const mergeSubRoom = (subscription) => {
retention: 1,
teamId: 1,
teamMain: 1,
onHold: 1,
metrics: 1,
servedBy: 1,
ts: 1,
waitingResponse: 1,
v: 1,
transcriptRequest: 1,
tags: 1,
closedAt: 1,
responseBy: 1,
priorityId: 1,
livechatData: 1,
departmentId: 1,
},
};
@ -196,6 +204,7 @@ const mergeSubRoom = (subscription) => {
responseBy,
priorityId,
livechatData,
departmentId,
ts,
} = room;
@ -229,6 +238,7 @@ const mergeSubRoom = (subscription) => {
responseBy,
priorityId,
livechatData,
departmentId,
ts,
});
};
@ -267,6 +277,7 @@ const mergeRoomSub = (room) => {
responseBy,
priorityId,
livechatData,
departmentId,
ts,
} = room;
@ -300,6 +311,7 @@ const mergeRoomSub = (room) => {
responseBy,
priorityId,
livechatData,
departmentId,
jitsiTimeout,
ts,
...getLowerCaseNames(room, sub.name, sub.fname),

@ -1,24 +1,14 @@
import { createContext, useContext } from 'react';
import { IRoom, IOmnichannelRoom, isOmnichannelRoom } from '../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../definition/ISubscription';
export type RoomContextValue = {
rid: IRoom['_id'];
room: IOmnichannelRoom & IOmnichannelSubscription;
room: IRoom;
};
export const RoomContext = createContext<RoomContextValue | null>(null);
const normalizeRoomSubscription = (
room: IOmnichannelRoom & IOmnichannelSubscription,
): IOmnichannelRoom => {
if (room.department) {
room.departmentId = room.department;
}
return room;
};
export const useRoom = (): IRoom => {
const { room } = useContext(RoomContext) || {};
if (!room) {
@ -37,5 +27,5 @@ export const useOmnichannelRoom = (): IOmnichannelRoom => {
throw new Error('invalid room type');
}
return normalizeRoomSubscription(room);
return room;
};

@ -1,8 +1,7 @@
import React, { ReactNode, useMemo, memo, useEffect } from 'react';
import { roomTypes } from '../../../../app/utils/client';
import { IRoom, IOmnichannelRoom } from '../../../../definition/IRoom';
import { IOmnichannelSubscription } from '../../../../definition/ISubscription';
import { IRoom } from '../../../../definition/IRoom';
import { RoomManager, useHandleRoom } from '../../../lib/RoomManager';
import { AsyncStatePhase } from '../../../lib/asyncState';
import Skeleton from '../Room/Skeleton';
@ -23,8 +22,7 @@ const RoomProvider = ({ rid, children }: Props): JSX.Element => {
room._id = rid;
return {
rid,
room: { ...room, name: roomTypes.getRoomName(room.t, room) } as IOmnichannelRoom &
IOmnichannelSubscription,
room: { ...room, name: roomTypes.getRoomName(room.t, room) },
};
}, [room, rid]);

@ -41,7 +41,7 @@ export interface ISubscription extends IRocketChatRecord {
}
export interface IOmnichannelSubscription extends ISubscription {
department?: string;
department?: string; // TODO REMOVE/DEPRECATE no need keeo in both room and subscription
}
export interface ISubscriptionDirectMessage extends Omit<ISubscription, 'name'> {

Loading…
Cancel
Save