Skip to content

Commit

Permalink
feat: exclude techical socket event listening
Browse files Browse the repository at this point in the history
  • Loading branch information
mebo4b committed Sep 15, 2021
1 parent fc847c9 commit 800a6c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/api/rocketChatSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ export class rocketChatSocket {
response.fields.eventName === params[0];
if (changeResponseOnSubscribedEvent) {
const newMessage =
response.collection === SOCKET_COLLECTION.ROOM_MESSAGES &&
!response.fields.args[0].u.username.starsWith(
response.collection === SOCKET_COLLECTION.ROOM_MESSAGES;
const isTechnicalMessage =
response.fields.args[0].u.username.starsWith(
'cob-rocket-chat-technical-user'
);
const roomClosed =
Expand All @@ -175,7 +176,7 @@ export class rocketChatSocket {
response.fields.args[1].u._id === this.rcUid;
const userTyping =
response.collection === SOCKET_COLLECTION.NOTIFY_ROOM;
if (newMessage && callbackRoom) {
if (newMessage && callbackRoom && !isTechnicalMessage) {
callbackRoom();
} else if (roomClosed && callbackUser) {
callbackUser();
Expand Down
3 changes: 2 additions & 1 deletion src/components/session/SessionView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export const SessionView = (props) => {
const [currentlyTypingUsers, setCurrentlyTypingUsers] = useState([]);
const [typingStatusSent, setTypingStatusSent] = useState(false);
const [isAnonymousEnquiry, setIsAnonymousEnquiry] = useState(false);
const isEnquiry = chatItem?.status === 1;
const isLiveChatFinished = chatItem?.status === 3;
const hasUserInitiatedStopOrLeaveRequest = useRef<boolean>(false);

Expand Down Expand Up @@ -124,7 +125,7 @@ export const SessionView = (props) => {
setLoadedMessages(messagesData);
setIsLoading(false);

if (!isSocketConnected && !isAnonymousEnquiry) {
if (!isSocketConnected && !isEnquiry) {
setSessionToRead();
window['socket'].connect();
window['socket'].addSubscription(
Expand Down

0 comments on commit 800a6c1

Please sign in to comment.