Fix livechat room breaking after return (#20089)

Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
pull/19953/head^2
gabriellsh 5 years ago committed by GitHub
parent 79f51f6b28
commit c13871a474
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      client/components/RoomForeword.js
  2. 15
      client/views/room/providers/RoomProvider.tsx
  3. 4
      client/views/room/providers/ToolboxProvider.tsx

@ -13,7 +13,7 @@ const RoomForeword = ({ _id: rid }) => {
const user = useUser();
const room = useReactiveValue(useCallback(() => Rooms.findOne({ _id: rid }), [rid]));
if (room.t !== 'd') {
if (room?.t !== 'd') {
return t('Start_of_conversation');
}

@ -20,11 +20,16 @@ const RoomProvider = ({ rid, children }: Props): JSX.Element => {
const _room = useUserRoom(rid, fields) as unknown as IRoom;
const room = uid ? subscription || _room : _room;
room._id = rid;
const context = useMemo(() => ({
rid,
room: { ...room, name: roomTypes.getRoomName(room.t, room) },
}), [room, rid]);
const context = useMemo(() => {
if (!room) {
return null;
}
room._id = rid;
return {
rid,
room: { ...room, name: roomTypes.getRoomName(room.t, room) },
};
}, [room, rid]);
if (!room) {
return <></>;

@ -1,5 +1,5 @@
import React, { ReactNode, useContext, useMemo, useState, useCallback, useLayoutEffect } from 'react';
import { useDebouncedState, useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useDebouncedState, useMutableCallback, useSafely } from '@rocket.chat/fuselage-hooks';
import { Handler } from '@rocket.chat/emitter';
import { ToolboxContext } from '../lib/Toolbox/ToolboxContext';
@ -56,7 +56,7 @@ export const ToolboxProvider = ({ children, room }: { children: ReactNode; room:
const allowAnonymousRead = useSetting('Accounts_AllowAnonymousRead');
const uid = useUserId();
const [activeTabBar, setActiveTabBar] = useState<[ToolboxActionConfig|undefined, string?]>([undefined]);
const [list, setList] = useDebouncedState<Store<ToolboxAction>>(new Map(), 5);
const [list, setList] = useSafely(useDebouncedState<Store<ToolboxAction>>(new Map(), 5));
const handleChange = useMutableCallback((fn) => { fn(list); setList((list) => new Map(list)); });
const { listen, actions } = useToolboxActions(room);

Loading…
Cancel
Save