2022-01-26 20:33:26 +09:00
|
|
|
/* 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() {
|
2022-02-27 20:32:03 +09:00
|
|
|
const { accountData } = initMatrix;
|
|
|
|
const [spaceShortcut, setSpaceShortcut] = useState([...accountData.spaceShortcut]);
|
2022-01-26 20:33:26 +09:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const onSpaceShortcutUpdated = () => {
|
2022-02-27 20:32:03 +09:00
|
|
|
setSpaceShortcut([...accountData.spaceShortcut]);
|
2022-01-26 20:33:26 +09:00
|
|
|
};
|
2022-02-27 20:32:03 +09:00
|
|
|
accountData.on(cons.events.accountData.SPACE_SHORTCUT_UPDATED, onSpaceShortcutUpdated);
|
2022-01-26 20:33:26 +09:00
|
|
|
return () => {
|
2022-02-27 20:32:03 +09:00
|
|
|
accountData.removeListener(
|
|
|
|
cons.events.accountData.SPACE_SHORTCUT_UPDATED,
|
|
|
|
onSpaceShortcutUpdated,
|
|
|
|
);
|
2022-01-26 20:33:26 +09:00
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return [spaceShortcut];
|
|
|
|
}
|