cinny/src/app/hooks/useMutualRooms.ts
Ajay Bura 4d1ae4eafd
Some checks failed
Deploy to Netlify (dev) / Deploy to Netlify (push) Has been cancelled
Redesign user profile view (#2396)
* WIP - new profile view

* render common rooms in user profile

* add presence component

* WIP - room user profile

* temp hide profile button

* show mutual rooms in spaces, rooms and direct messages categories

* add message button

* add option to change user powers in profile

* improve ban info and option to unban

* add share user button in user profile

* add option to block user in user profile

* improve blocked user alert body

* add moderation tool in user profile

* open profile view on left side in member drawer

* open new user profile in all places
2025-08-09 22:16:10 +10:00

30 lines
955 B
TypeScript

import { useCallback } from 'react';
import { useMatrixClient } from './useMatrixClient';
import { AsyncState, useAsyncCallbackValue } from './useAsyncCallback';
import { useSpecVersions } from './useSpecVersions';
export const useMutualRoomsSupport = (): boolean => {
const { unstable_features: unstableFeatures } = useSpecVersions();
const supported =
unstableFeatures?.['uk.half-shot.msc2666'] ||
unstableFeatures?.['uk.half-shot.msc2666.mutual_rooms'] ||
unstableFeatures?.['uk.half-shot.msc2666.query_mutual_rooms'];
return !!supported;
};
export const useMutualRooms = (userId: string): AsyncState<string[], unknown> => {
const mx = useMatrixClient();
const supported = useMutualRoomsSupport();
const [mutualRoomsState] = useAsyncCallbackValue(
useCallback(
() => (supported ? mx._unstable_getSharedRooms(userId) : Promise.resolve([])),
[mx, userId, supported]
)
);
return mutualRoomsState;
};