Regression: Fix omnichannel empty source usage (#24008)

improve/Dropdown^2
Guilherme Gazzo 3 years ago committed by GitHub
parent 160619d2ac
commit 84da0abb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      client/components/RoomIcon/OmnichannelRoomIcon/OmnichannelCoreSourceRoomIcon.tsx
  2. 2
      client/hooks/useRoomIcon.tsx
  3. 3
      client/views/omnichannel/directory/chats/contextualBar/ChatInfo.js
  4. 4
      definition/IRoom.ts

@ -26,6 +26,6 @@ export const OmnichannelCoreSourceRoomIcon = ({
room: IOmnichannelRoom; room: IOmnichannelRoom;
size: ComponentProps<typeof Icon>['size']; size: ComponentProps<typeof Icon>['size'];
}): ReactElement => { }): ReactElement => {
const icon = iconMap[room.source.type] || 'headset'; const icon = iconMap[room.source?.type || 'other'] || 'headset';
return <Icon name={icon} size={size} color={colors[room.v.status || 'offline']} />; return <Icon name={icon} size={size} color={colors[room.v.status || 'offline']} />;
}; };

@ -28,7 +28,7 @@ export const useRoomIcon = (room: IRoom): ReactNode | { name: string; color?: st
app: 'headset', // TODO: use app icon app: 'headset', // TODO: use app icon
api: 'headset', // TODO: use api icon api: 'headset', // TODO: use api icon
other: 'headset', other: 'headset',
}[room.source.type] || 'headset'; }[room.source?.type || 'other'] || 'headset';
return { return {
name: icon, name: icon,

@ -25,6 +25,7 @@ import PriorityField from './PriorityField';
import SourceField from './SourceField'; import SourceField from './SourceField';
import VisitorClientInfo from './VisitorClientInfo'; import VisitorClientInfo from './VisitorClientInfo';
// TODO: Remove moment we are mixing moment and our own formatters :sadface:
function ChatInfo({ id, route }) { function ChatInfo({ id, route }) {
const t = useTranslation(); const t = useTranslation();
@ -54,8 +55,10 @@ function ChatInfo({ id, route }) {
} = room || { room: { v: {} } }; } = room || { room: { v: {} } };
const routePath = useRoute(route || 'omnichannel-directory'); const routePath = useRoute(route || 'omnichannel-directory');
// TODO: use hook instead
const canViewCustomFields = () => hasPermission('view-livechat-room-customfields'); const canViewCustomFields = () => hasPermission('view-livechat-room-customfields');
const subscription = useUserSubscription(id); const subscription = useUserSubscription(id);
// TODO: use hook instead
const hasGlobalEditRoomPermission = hasPermission('save-others-livechat-room-info'); const hasGlobalEditRoomPermission = hasPermission('save-others-livechat-room-info');
const hasLocalEditRoomPermission = servedBy?._id === Meteor.userId(); const hasLocalEditRoomPermission = servedBy?._id === Meteor.userId();
const visitorId = v?._id; const visitorId = v?._id;

@ -121,7 +121,7 @@ export interface IOmnichannelRoom extends Omit<IRoom, 'default' | 'featured' | '
replyTo: string; replyTo: string;
subject: string; subject: string;
}; };
source: { source: { // TODO: looks like this is not so required as the definition suggests
// The source, or client, which created the Omnichannel room // The source, or client, which created the Omnichannel room
type: OmnichannelSourceType; type: OmnichannelSourceType;
// An optional identification of external sources, such as an App // An optional identification of external sources, such as an App
@ -175,5 +175,5 @@ export const isOmnichannelRoomFromAppSource = (room: IRoom): room is IOmnichanne
return false; return false;
} }
return room.source.type === OmnichannelSourceType.APP; return room.source?.type === OmnichannelSourceType.APP;
}; };

Loading…
Cancel
Save