mirror of
https://github.com/array-in-a-matrix/xinny.git
synced 2024-05-17 20:00:17 -04:00
8583ab19f0
* Add options to display/ignore usersId's * Update string * Hide search icon in encrypted rooms (#763) * Fix styles
23 lines
596 B
JavaScript
23 lines
596 B
JavaScript
/* eslint-disable import/prefer-default-export */
|
|
import { useState, useEffect } from 'react';
|
|
|
|
import initMatrix from '../../client/initMatrix';
|
|
|
|
export function useAccountData(eventType) {
|
|
const mx = initMatrix.matrixClient;
|
|
const [event, setEvent] = useState(mx.getAccountData(eventType));
|
|
|
|
useEffect(() => {
|
|
const handleChange = (mEvent) => {
|
|
if (mEvent.getType() !== eventType) return;
|
|
setEvent(mEvent);
|
|
};
|
|
mx.on('accountData', handleChange);
|
|
return () => {
|
|
mx.removeListener('accountData', handleChange);
|
|
};
|
|
}, [eventType]);
|
|
|
|
return event;
|
|
}
|