Refactor navigation

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2022-01-26 17:03:26 +05:30
parent f47998a553
commit 992da7c7be
7 changed files with 130 additions and 55 deletions

View file

@ -0,0 +1,22 @@
/* eslint-disable import/prefer-default-export */
import { useState, useEffect } from 'react';
import initMatrix from '../../client/initMatrix';
import cons from '../../client/state/cons';
export function useSpaceShortcut() {
const { roomList } = initMatrix;
const [spaceShortcut, setSpaceShortcut] = useState([...roomList.spaceShortcut]);
useEffect(() => {
const onSpaceShortcutUpdated = () => {
setSpaceShortcut([...roomList.spaceShortcut]);
};
roomList.on(cons.events.roomList.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
return () => {
roomList.removeListener(cons.events.roomList.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
};
}, []);
return [spaceShortcut];
}