Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Contact Bar not reactive #22016

Merged
merged 28 commits into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a31e104
WIP
ggazzo Apr 20, 2021
b5ea0e9
Bump
ggazzo May 12, 2021
d27efc5
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
ggazzo May 12, 2021
d02f1cc
ContactContetualBar -> TS
ggazzo May 12, 2021
6aa496e
Opss
ggazzo May 12, 2021
1ec97a3
méeeee
ggazzo May 12, 2021
1c71d05
done
ggazzo May 12, 2021
128171f
Merge branch 'develop' into feat/help-omni
ggazzo May 13, 2021
2742839
Merge branch 'feat/help-omni' of github.com:RocketChat/Rocket.Chat in…
ggazzo May 13, 2021
0b6f742
fix
ggazzo May 13, 2021
6488c5a
??
ggazzo May 13, 2021
36e8eba
TS fix
ggazzo May 13, 2021
3ed7a26
remove tabId from quickactions component
tiagoevanp May 13, 2021
480d4cb
Fix onhold missing
ggazzo May 13, 2021
11deba7
Merge branch 'feat/help-omni' of github.com:RocketChat/Rocket.Chat in…
tiagoevanp May 13, 2021
0c444ea
prevent error with no contact
rafaelblink May 13, 2021
c1c9118
prepare directory chatinfo to use the the endpoint instead the hook u…
rafaelblink May 13, 2021
fca43d0
Canelada
ggazzo May 13, 2021
203fb88
Merge branch 'feat/help-omni' of github.com:RocketChat/Rocket.Chat in…
ggazzo May 13, 2021
2f00c06
fix identation
rafaelblink May 13, 2021
336b583
Merge branch 'feat/help-omni' of github.com:RocketChat/Rocket.Chat in…
tiagoevanp May 13, 2021
b080b93
fix stream issues
tiagoevanp May 14, 2021
2ea92a7
fix resume chat onhold
tiagoevanp May 14, 2021
54c0f79
remove unnecessary import
tiagoevanp May 14, 2021
b10b907
missed fields chat info panel
rafaelblink May 14, 2021
2826b65
Merge branch 'develop' into feat/help-omni
rafaelblink May 14, 2021
9021d55
ChatsContextualBar reactive
tiagoevanp May 14, 2021
f455491
Allow agents to edit rooms on contact center.
renatobecker May 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/threads/client/components/ThreadComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const ThreadComponent: FC<{
}, [dispatchToastMessage, followMessage, unfollowMessage, mid]);

const handleClose = useCallback(() => {
channelRoute.push(room.t === 'd' ? { rid: room._id } : { name: room.name });
channelRoute.push(room.t === 'd' ? { rid: room._id } : { name: room.name || room._id });
}, [channelRoute, room._id, room.t, room.name]);

const [viewData, setViewData] = useState(() => ({
Expand Down
161 changes: 122 additions & 39 deletions app/ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,65 +161,148 @@ const mergeSubRoom = (subscription) => {
retention: 1,
teamId: 1,
teamMain: 1,
onHold: 1,
metrics: 1,
servedBy: 1,
ts: 1,
waitingResponse: 1,
},
};

const room = Rooms.findOne({ _id: subscription.rid }, options) || { };

const lastRoomUpdate = room.lm || subscription.ts || subscription._updatedAt;

if (room.uids) {
subscription.uids = room.uids;
}

if (room.v) {
subscription.v = room.v;
}

subscription.usernames = room.usernames;
const {
encrypted,
description,
cl,
topic,
announcement,
broadcast,
archived,
retention,
lastMessage,
streamingOptions,
teamId,
teamMain,
uids,
usernames,

v,
transcriptRequest,
servedBy,
onHold,
tags,
closedAt,
metrics,
waitingResponse,
responseBy,
priorityId,
livechatData,
ts,
} = room;

subscription.lastMessage = room.lastMessage;
subscription.lm = subscription.lr ? new Date(Math.max(subscription.lr, lastRoomUpdate)) : lastRoomUpdate;
subscription.streamingOptions = room.streamingOptions;

subscription.encrypted = room.encrypted;
subscription.description = room.description;
subscription.cl = room.cl;
subscription.topic = room.topic;
subscription.announcement = room.announcement;
subscription.broadcast = room.broadcast;
subscription.archived = room.archived;
subscription.retention = room.retention;

subscription.teamId = room.teamId;
subscription.teamMain = room.teamMain;
return Object.assign(subscription, getLowerCaseNames(subscription));

return Object.assign(subscription, getLowerCaseNames(subscription), {
encrypted,
description,
cl,
topic,
announcement,
broadcast,
archived,
retention,
lastMessage,
streamingOptions,
teamId,
teamMain,
uids,
usernames,

v,
transcriptRequest,
servedBy,
onHold,
tags,
closedAt,
metrics,
waitingResponse,
responseBy,
priorityId,
livechatData,
ts,
});
};

const mergeRoomSub = (room) => {
const sub = Subscriptions.findOne({ rid: room._id });
if (!sub) {
return room;
}

const {
encrypted,
description,
cl,
topic,
announcement,
broadcast,
archived,
retention,
lastMessage,
streamingOptions,
teamId,
teamMain,
uids,
usernames,

v,
transcriptRequest,
servedBy,
onHold,
tags,
closedAt,
metrics,
waitingResponse,
responseBy,
priorityId,
livechatData,
ts,

} = room;

Subscriptions.update({
rid: room._id,
}, {
$set: {
encrypted: room.encrypted,
description: room.description,
cl: room.cl,
topic: room.topic,
announcement: room.announcement,
broadcast: room.broadcast,
archived: room.archived,
retention: room.retention,
...Array.isArray(room.uids) && { uids: room.uids },
...Array.isArray(room.uids) && { usernames: room.usernames },
...room.v && { v: room.v },
lastMessage: room.lastMessage,
streamingOptions: room.streamingOptions,
teamId: room.teamId,
teamMain: room.teamMain,
encrypted,
description,
cl,
topic,
announcement,
broadcast,
archived,
retention,
uids,
usernames,
lastMessage,
streamingOptions,
teamId,
teamMain,
v,
transcriptRequest,
servedBy,
onHold,
tags,
closedAt,
metrics,
waitingResponse,
responseBy,
priorityId,
livechatData,
ts,
...getLowerCaseNames(room, sub.name, sub.fname),
},
});
Expand Down
17 changes: 17 additions & 0 deletions client/components/ErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Component } from 'react';

export class ErrorBoundary extends Component {
state = { hasError: false };

static getDerivedStateFromError() {
return { hasError: true };
}

render() {
if (this.state.hasError) {
return null;
}

return this.props.children;
}
}
6 changes: 3 additions & 3 deletions client/components/Omnichannel/modals/TranscriptModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Field, Button, TextInput, Icon, ButtonGroup, Modal } from '@rocket.chat
import { useAutoFocus } from '@rocket.chat/fuselage-hooks';
import React, { FC, useCallback, useEffect, useState, useMemo } from 'react';

import { IRoom } from '../../../../definition/IRoom';
import { IOmnichannelRoom } from '../../../../definition/IRoom';
import { useTranslation } from '../../../contexts/TranslationContext';
import { useComponentDidUpdate } from '../../../hooks/useComponentDidUpdate';
import { useForm } from '../../../hooks/useForm';

type TranscriptModalProps = {
email: string;
room?: IRoom;
room: IOmnichannelRoom;
onRequest: (email: string, subject: string) => void;
onSend?: (email: string, subject: string, token: string) => void;
onCancel: () => void;
Expand Down Expand Up @@ -38,7 +38,7 @@ const TranscriptModal: FC<TranscriptModalProps> = ({
const { handleEmail, handleSubject } = handlers;
const [emailError, setEmailError] = useState('');
const [subjectError, setSubjectError] = useState('');
const { transcriptRequest } = (room as unknown) as IRoom;
const { transcriptRequest } = room;
const roomOpen = room && room.open;
const token = room?.v?.token;

Expand Down
8 changes: 4 additions & 4 deletions client/lib/RoomManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ const subscribeOpenedRoom: Subscription<IRoom['_id'] | undefined> = {

const fields = {};

export const useHandleRoom = (rid: IRoom['_id']): AsyncState<IRoom> => {
const { resolve, update, ...state } = useAsyncState<IRoom>();
export const useHandleRoom = <T extends IRoom>(rid: IRoom['_id']): AsyncState<T> => {
const { resolve, update, ...state } = useAsyncState<T>();
const uid = useUserId();
const subscription = (useUserSubscription(rid, fields) as unknown) as IRoom;
const _room = (useUserRoom(rid, fields) as unknown) as IRoom;
const subscription = (useUserSubscription(rid, fields) as unknown) as T;
const _room = (useUserRoom(rid, fields) as unknown) as T;

const room = uid ? subscription || _room : _room;

Expand Down
25 changes: 23 additions & 2 deletions client/views/omnichannel/directory/ChatsContextualBar.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Box } from '@rocket.chat/fuselage';
import React from 'react';

import VerticalBar from '../../../components/VerticalBar';
import { useRoute, useRouteParameter } from '../../../contexts/RouterContext';
import { useTranslation } from '../../../contexts/TranslationContext';
import { AsyncStatePhase } from '../../../hooks/useAsyncState';
import { useEndpointData } from '../../../hooks/useEndpointData';
import { FormSkeleton } from './Skeleton';
import Chat from './chats/Chat';
import ChatInfo from './chats/contextualBar/ChatInfo';
import ChatInfoDirectory from './chats/contextualBar/ChatInfoDirectory';
import RoomEditWithData from './chats/contextualBar/RoomEditWithData';

const ChatsContextualBar = ({ chatReload }) => {
Expand All @@ -27,10 +31,26 @@ const ChatsContextualBar = ({ chatReload }) => {
directoryRoute.push({ page: 'chats', id, bar: 'info' });
};

const { value: data, phase: state, error, reload: reloadInfo } = useEndpointData(
`rooms.info?roomId=${id}`,
);

if (bar === 'view') {
return <Chat rid={id} />;
}

if (state === AsyncStatePhase.LOADING) {
return (
<Box pi='x24'>
<FormSkeleton />
</Box>
);
}

if (error || !data || !data.room) {
return <Box mbs='x16'>{t('Room_not_found')}</Box>;
}

return (
<VerticalBar className={'contextual-bar'}>
<VerticalBar.Header>
Expand All @@ -53,12 +73,13 @@ const ChatsContextualBar = ({ chatReload }) => {
)}
<VerticalBar.Close onClick={handleChatsVerticalBarCloseButtonClick} />
</VerticalBar.Header>
{bar === 'info' && <ChatInfo id={id} />}
{bar === 'info' && <ChatInfoDirectory id={id} room={data.room} />}
{bar === 'edit' && (
<RoomEditWithData
id={id}
close={handleChatsVerticalBarBackButtonClick}
reload={chatReload}
reloadInfo={reloadInfo}
/>
)}
</VerticalBar>
Expand Down
4 changes: 0 additions & 4 deletions client/views/omnichannel/directory/ContactContextualBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ import ContactNewEdit from './contacts/contextualBar/ContactNewEdit';
const ContactContextualBar = ({ contactReload }) => {
const directoryRoute = useRoute('omnichannel-directory');
const bar = useRouteParameter('bar');
const page = useRouteParameter('page');
const tab = useRouteParameter('tab');
const id = useRouteParameter('id');

console.log(bar, tab, page, id);

const t = useTranslation();

const handleContactsVerticalBarCloseButtonClick = () => {
Expand Down
Loading