mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Refactor navigation
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
f47998a553
commit
992da7c7be
7 changed files with 130 additions and 55 deletions
22
src/app/hooks/useSpaceShortcut.js
Normal file
22
src/app/hooks/useSpaceShortcut.js
Normal 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];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue