feat(call): add docked call panel and remote cursor overlay
- Implemented DockedCallPanel component to render the docked call interface when an active call is present. - Created RemoteCursorOverlay component to display remote cursor positions during screen sharing. - Added hooks for managing docked call state and remote cursor functionality. - Introduced pending drag state management for seamless transitions between docked and floating states. - Developed embed filter management components for personal and room-wide settings, allowing users to customize URL embed visibility. - Implemented auto-joining functionality for rooms within spaces, enhancing user experience during space navigation. - Added state management for tracking joining progress of rooms in spaces.
This commit is contained in:
@@ -17,6 +17,7 @@ export type SidebarItems = Array<TSidebarItem>;
|
||||
export type InCinnySpacesContent = {
|
||||
shortcut?: string[];
|
||||
sidebar?: SidebarItems;
|
||||
hidden?: string[];
|
||||
};
|
||||
|
||||
export const parseSidebar = (
|
||||
@@ -25,12 +26,14 @@ export const parseSidebar = (
|
||||
content?: InCinnySpacesContent
|
||||
) => {
|
||||
const sidebar = content?.sidebar ?? content?.shortcut ?? [];
|
||||
const hiddenSet = new Set(content?.hidden ?? []);
|
||||
const orphans = new Set(orphanSpaces);
|
||||
|
||||
const items: SidebarItems = [];
|
||||
|
||||
const safeToAdd = (spaceId: string): boolean => {
|
||||
if (typeof spaceId !== 'string') return false;
|
||||
if (hiddenSet.has(spaceId)) return false;
|
||||
const space = mx.getRoom(spaceId);
|
||||
if (space?.getMyMembership() !== Membership.Join) return false;
|
||||
return isSpace(space);
|
||||
@@ -52,17 +55,39 @@ export const parseSidebar = (
|
||||
) {
|
||||
const safeContent = item.content.filter(safeToAdd);
|
||||
safeContent.forEach((i) => orphans.delete(i));
|
||||
items.push({
|
||||
...item,
|
||||
content: Array.from(new Set(safeContent)),
|
||||
});
|
||||
if (safeContent.length > 0) {
|
||||
items.push({
|
||||
...item,
|
||||
content: Array.from(new Set(safeContent)),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
orphans.forEach((spaceId) => items.push(spaceId));
|
||||
orphans.forEach((spaceId) => {
|
||||
if (!hiddenSet.has(spaceId)) {
|
||||
items.push(spaceId);
|
||||
}
|
||||
});
|
||||
return items;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse hidden spaces from account data
|
||||
*/
|
||||
export const parseHiddenSpaces = (
|
||||
mx: MatrixClient,
|
||||
content?: InCinnySpacesContent
|
||||
): string[] => {
|
||||
const hidden = content?.hidden ?? [];
|
||||
return hidden.filter((spaceId) => {
|
||||
if (typeof spaceId !== 'string') return false;
|
||||
const space = mx.getRoom(spaceId);
|
||||
if (space?.getMyMembership() !== Membership.Join) return false;
|
||||
return isSpace(space);
|
||||
});
|
||||
};
|
||||
|
||||
export const useSidebarItems = (
|
||||
orphanSpaces: string[]
|
||||
): [SidebarItems, Dispatch<SetStateAction<SidebarItems>>] => {
|
||||
@@ -136,3 +161,80 @@ export const makeCinnySpacesContent = (
|
||||
|
||||
return newSpacesContent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to get and manage hidden spaces
|
||||
*/
|
||||
export const useHiddenSpaces = (): [string[], Dispatch<SetStateAction<string[]>>] => {
|
||||
const mx = useMatrixClient();
|
||||
|
||||
const [hiddenSpaces, setHiddenSpaces] = useState(() => {
|
||||
const content = getAccountData(
|
||||
mx,
|
||||
AccountDataEvent.CinnySpaces
|
||||
)?.getContent<InCinnySpacesContent>();
|
||||
return parseHiddenSpaces(mx, content);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const content = getAccountData(
|
||||
mx,
|
||||
AccountDataEvent.CinnySpaces
|
||||
)?.getContent<InCinnySpacesContent>();
|
||||
setHiddenSpaces(parseHiddenSpaces(mx, content));
|
||||
}, [mx]);
|
||||
|
||||
useAccountDataCallback(
|
||||
mx,
|
||||
useCallback(
|
||||
(mEvent) => {
|
||||
if (mEvent.getType() === AccountDataEvent.CinnySpaces) {
|
||||
const newContent = mEvent.getContent<InCinnySpacesContent>();
|
||||
setHiddenSpaces(parseHiddenSpaces(mx, newContent));
|
||||
}
|
||||
},
|
||||
[mx]
|
||||
)
|
||||
);
|
||||
|
||||
return [hiddenSpaces, setHiddenSpaces];
|
||||
};
|
||||
|
||||
/**
|
||||
* Create content for hiding a space
|
||||
*/
|
||||
export const makeHideSpaceContent = (
|
||||
mx: MatrixClient,
|
||||
spaceId: string
|
||||
): InCinnySpacesContent => {
|
||||
const currentContent =
|
||||
getAccountData(mx, AccountDataEvent.CinnySpaces)?.getContent<InCinnySpacesContent>() ?? {};
|
||||
|
||||
const currentHidden = currentContent.hidden ?? [];
|
||||
if (currentHidden.includes(spaceId)) {
|
||||
return currentContent;
|
||||
}
|
||||
|
||||
return {
|
||||
...currentContent,
|
||||
hidden: [...currentHidden, spaceId],
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Create content for unhiding a space
|
||||
*/
|
||||
export const makeUnhideSpaceContent = (
|
||||
mx: MatrixClient,
|
||||
spaceId: string
|
||||
): InCinnySpacesContent => {
|
||||
const currentContent =
|
||||
getAccountData(mx, AccountDataEvent.CinnySpaces)?.getContent<InCinnySpacesContent>() ?? {};
|
||||
|
||||
const currentHidden = currentContent.hidden ?? [];
|
||||
|
||||
return {
|
||||
...currentContent,
|
||||
hidden: currentHidden.filter((id) => id !== spaceId),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user