Fix roomlist not updating live

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-03-03 18:46:47 +05:30
parent a05b96e9a0
commit 6b9c8b7a87

View file

@ -13,6 +13,7 @@ import DrawerBreadcrumb from './DrawerBreadcrumb';
import Home from './Home'; import Home from './Home';
import Directs from './Directs'; import Directs from './Directs';
import { useForceUpdate } from '../../hooks/useForceUpdate';
import { useSelectedTab } from '../../hooks/useSelectedTab'; import { useSelectedTab } from '../../hooks/useSelectedTab';
import { useSelectedSpace } from '../../hooks/useSelectedSpace'; import { useSelectedSpace } from '../../hooks/useSelectedSpace';
@ -39,8 +40,17 @@ function Drawer() {
const [systemState] = useSystemState(); const [systemState] = useSystemState();
const [selectedTab] = useSelectedTab(); const [selectedTab] = useSelectedTab();
const [spaceId] = useSelectedSpace(); const [spaceId] = useSelectedSpace();
const [, forceUpdate] = useForceUpdate();
const scrollRef = useRef(null); const scrollRef = useRef(null);
useEffect(() => {
const { roomList } = initMatrix;
roomList.on(cons.events.roomList.ROOMLIST_UPDATED, forceUpdate);
return () => {
roomList.removeListener(cons.events.roomList.ROOMLIST_UPDATED, forceUpdate);
};
}, []);
useEffect(() => { useEffect(() => {
requestAnimationFrame(() => { requestAnimationFrame(() => {
scrollRef.current.scrollTop = 0; scrollRef.current.scrollTop = 0;