add room account data hook
This commit is contained in:
parent
7787055df1
commit
bdb9abb2e2
1 changed files with 20 additions and 0 deletions
20
src/app/hooks/storage/useRoomAccountData.ts
Normal file
20
src/app/hooks/storage/useRoomAccountData.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { PendingObservableResult } from 'neurone/lib/utils/observable';
|
||||
import { useMemo } from 'react';
|
||||
import { JoinAccountDataObject } from '../../../client/storage/collections';
|
||||
import { useClient } from '../useClient';
|
||||
import { useObservableValuePromise } from '../useObservableValue';
|
||||
|
||||
export const useRoomAccountData = (
|
||||
roomId: string
|
||||
): PendingObservableResult<JoinAccountDataObject[]> => {
|
||||
const ct = useClient();
|
||||
|
||||
const eventsPromise = useMemo(
|
||||
() => ct.storage.joinAccountData.observableRead.queryIndex('roomId', roomId),
|
||||
[ct, roomId]
|
||||
);
|
||||
|
||||
const eventsResult = useObservableValuePromise(eventsPromise);
|
||||
|
||||
return eventsResult;
|
||||
};
|
||||
Loading…
Reference in a new issue