Skip to content

Commit

Permalink
Update usePersistentDeviceSettings to
Browse files Browse the repository at this point in the history
usePersistentUserChoices
  • Loading branch information
Ocupe committed Nov 6, 2023
1 parent f343737 commit 2911f10
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export { UseVisualStableUpdateOptions, useVisualStableUpdate } from './useVisual
export { UseTrackOptions, useTrack } from './useTrack';
export { useTrackByName } from './useTrackByName';
export { useChat } from './useChat';
export { usePersistentDeviceSettings } from './usePersistentDeviceSettings';
export { usePersistentUserChoices } from './usePersistentUserChoices';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from 'react';
* Options for the `usePersistentDeviceSettings` hook.
* @alpha
*/
interface UsePersistentDeviceSettingsOptions {
interface UsePersistentUserChoicesOptions {
/**
* The default value to use if reading from local storage returns no results or fails.
*/
Expand All @@ -19,12 +19,11 @@ interface UsePersistentDeviceSettingsOptions {
}

/**
* A hook that provides access to persistent device settings stored in local storage.
* @param fallbackValues - The initial value to use if no stored value is found.
* @returns A tuple containing the stored value and a function to update the stored value.
* A hook that provides access to user choices stored in local storage, such as
* selected media devices and their current state, as well as the user name.
* @alpha
*/
export function usePersistentDeviceSettings(options: UsePersistentDeviceSettingsOptions = {}) {
export function usePersistentUserChoices(options: UsePersistentUserChoicesOptions = {}) {
const [deviceSettings, setSettings] = React.useState<DeviceSettings>(
getDeviceSettings(options.defaults),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/prefabs/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { TrackToggle } from '../components/controls/TrackToggle';
import { StartAudio } from '../components/controls/StartAudio';
import { ChatIcon, LeaveIcon } from '../assets/icons';
import { ChatToggle } from '../components/controls/ChatToggle';
import { useLocalParticipantPermissions, usePersistentDeviceSettings } from '../hooks';
import { useLocalParticipantPermissions, usePersistentUserChoices } from '../hooks';
import { useMediaQuery } from '../hooks/internal';
import { useMaybeLayoutContext } from '../context';
import { supportsScreenSharing } from '@livekit/components-core';
Expand Down Expand Up @@ -107,7 +107,7 @@ export function ControlBar({
saveVideoInputEnabled,
saveAudioInputDeviceId,
saveVideoInputDeviceId,
} = usePersistentDeviceSettings({ preventSave: !saveDeviceSettings });
} = usePersistentUserChoices({ preventSave: !saveDeviceSettings });

return (
<div {...htmlProps}>
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/prefabs/PreJoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MediaDeviceMenu } from './MediaDeviceMenu';
import { TrackToggle } from '../components/controls/TrackToggle';
import { log } from '@livekit/components-core';
import { ParticipantPlaceholder } from '../assets/images';
import { useMediaDevices, usePersistentDeviceSettings } from '../hooks';
import { useMediaDevices, usePersistentUserChoices } from '../hooks';

/** @public */
export type LocalUserChoices = {
Expand Down Expand Up @@ -244,7 +244,7 @@ export function PreJoin({
saveAudioInputEnabled,
saveVideoInputDeviceId,
saveVideoInputEnabled,
} = usePersistentDeviceSettings({
} = usePersistentUserChoices({
defaults: {
audioInputDeviceId: DEFAULT_USER_CHOICES.audioDeviceId,
videoInputDeviceId: DEFAULT_USER_CHOICES.videoDeviceId,
Expand Down

0 comments on commit 2911f10

Please sign in to comment.