mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 15:00:30 +03:00
Move space shortcut from roomlist to accountdata
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
7db674b65d
commit
a62df536dd
10 changed files with 131 additions and 77 deletions
|
|
@ -5,16 +5,19 @@ import initMatrix from '../../client/initMatrix';
|
|||
import cons from '../../client/state/cons';
|
||||
|
||||
export function useSpaceShortcut() {
|
||||
const { roomList } = initMatrix;
|
||||
const [spaceShortcut, setSpaceShortcut] = useState([...roomList.spaceShortcut]);
|
||||
const { accountData } = initMatrix;
|
||||
const [spaceShortcut, setSpaceShortcut] = useState([...accountData.spaceShortcut]);
|
||||
|
||||
useEffect(() => {
|
||||
const onSpaceShortcutUpdated = () => {
|
||||
setSpaceShortcut([...roomList.spaceShortcut]);
|
||||
setSpaceShortcut([...accountData.spaceShortcut]);
|
||||
};
|
||||
roomList.on(cons.events.roomList.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
|
||||
accountData.on(cons.events.accountData.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
|
||||
return () => {
|
||||
roomList.removeListener(cons.events.roomList.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
|
||||
accountData.removeListener(
|
||||
cons.events.accountData.SPACE_SHORTCUT_UPDATED,
|
||||
onSpaceShortcutUpdated,
|
||||
);
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue