Skip to content

Commit

Permalink
[FCE-930] Add useUpdatePeerMetadata hook (#203)
Browse files Browse the repository at this point in the history
## Description

Add new `useUpdatePeerMetadata` hook, that would allow to update
metadata after connection.

I've tested it with small code added in example app - it worked as
expected.

## Motivation and Context

Right now it is not possible to update metadata in web sdk.

## Types of changes

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to
      not work as expected)
  • Loading branch information
mironiasty authored Nov 27, 2024
1 parent f66f72f commit a8922b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react-client/src/hooks/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export { useInitializeDevices } from "./devices/useInitializeDevices";
export { usePeers } from "./usePeers";
export { useScreenShare } from "./useScreenShare";
export { useStatus } from "./useStatus";
export { useUpdatePeerMetadata } from "./useUpdatePeerMetadata";
export { useVAD } from "./useVAD";
16 changes: 16 additions & 0 deletions packages/react-client/src/hooks/useUpdatePeerMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useCallback } from "react";
import { useFishjamContext } from "./useFishjamContext";
import type { GenericMetadata } from "@fishjam-cloud/ts-client";

export const useUpdatePeerMetadata = <PeerMetadata = GenericMetadata>() => {
const { fishjamClientRef } = useFishjamContext();

const updatePeerMetadata = useCallback(
(peerMetadata: PeerMetadata) => {
fishjamClientRef.current.updatePeerMetadata(peerMetadata as GenericMetadata);
},
[fishjamClientRef],
);

return { updatePeerMetadata };
};
1 change: 1 addition & 0 deletions packages/react-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
usePeers,
useScreenShare,
useStatus,
useUpdatePeerMetadata,
useVAD,
} from "./hooks/public";
export { FishjamProvider } from "./fishjamProvider";
Expand Down

0 comments on commit a8922b4

Please sign in to comment.