Skip to content

Commit

Permalink
fix(*): fix yarn lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Feb 20, 2024
1 parent aab8a85 commit 5790889
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
7 changes: 5 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {
StatusBar,
Animated,
} from 'react-native';
import { ApiVideoLiveStreamView, PredefinedResolution } from '@api.video/react-native-livestream';
import {
ApiVideoLiveStreamView,
PredefinedResolution,
} from '@api.video/react-native-livestream';
import Icon from 'react-native-vector-icons/Ionicons';
import styles, { button } from './style';
import Settings from './components/settings';
Expand Down Expand Up @@ -35,7 +38,7 @@ export default function App() {
message: string;
}>({ display: false, message: '' });
const [settings, setSettings] = React.useState<ISettingsState>({
resolution: "360p",
resolution: '360p',
framerate: 30,
videoBitrate: assets.sections.video.Bitrate.min,
audioBitrate: 64000,
Expand Down
1 change: 0 additions & 1 deletion example/src/components/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import assets from '../../assets';
import type { ISettingsState } from 'example/src/App';
import type { PredefinedResolution } from '@api.video/react-native-livestream';


interface ISettingsProps {
closeSettings: () => void;
settings: ISettingsState;
Expand Down
3 changes: 1 addition & 2 deletions src/NativeApiVideoLiveStreamView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ export type Resolution = Readonly<{
height: Int32;
}>;

export type PredefinedResolution = "240p" | "360p" | "480p" | "720p" | "1080p";

export type PredefinedResolution = '240p' | '360p' | '480p' | '720p' | '1080p';

export type OnConnectionFailedEvent = Readonly<{
code: string;
Expand Down
30 changes: 17 additions & 13 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type ApiVideoLiveStreamProps = {
isStereo?: boolean;
};
zoomRatio?: number;
enablePinchedZoom: boolean;
enablePinchedZoom?: boolean;

onConnectionSuccess?: () => void;
onConnectionFailed?: (code: string) => void;
Expand Down Expand Up @@ -77,23 +77,24 @@ const getDefaultBitrate = (resolution: Resolution): number => {
}
};


function resolveResolution(resolution: Resolution | PredefinedResolution): Resolution {
function resolveResolution(
resolution: Resolution | PredefinedResolution
): Resolution {
const predefinedResolutions: Record<PredefinedResolution, Resolution> = {
"1080p": { width: 1920, height: 1080 },
"720p": { width: 1280, height: 720 },
"480p": { width: 854, height: 480 },
"360p": { width: 640, height: 360 },
"240p": { width: 352, height: 240 },
'1080p': { width: 1920, height: 1080 },
'720p': { width: 1280, height: 720 },
'480p': { width: 854, height: 480 },
'360p': { width: 640, height: 360 },
'240p': { width: 352, height: 240 },
};

if (typeof resolution === "string") {
if (typeof resolution === 'string') {
const predefined = predefinedResolutions[resolution];
if (!predefined) {
throw new Error("Unknown resolution");
throw new Error('Unknown resolution');
}
return predefined;
}
}
return {
width: Math.max(resolution.height, resolution.width),
height: Math.min(resolution.height, resolution.width),
Expand All @@ -104,7 +105,7 @@ const ApiVideoLiveStreamView = forwardRef<
ApiVideoLiveStreamMethods,
ApiVideoLiveStreamProps
>((props, forwardedRef) => {
const resolution = resolveResolution(props.video?.resolution || "720p")
const resolution = resolveResolution(props.video?.resolution || '720p');
const nativeLiveStreamProps: NativeLiveStreamProps = {
...LIVE_STREAM_PROPS_DEFAULTS,
...props,
Expand Down Expand Up @@ -217,4 +218,7 @@ const ApiVideoLiveStreamView = forwardRef<
});

export { ApiVideoLiveStreamView };
export type { Resolution, PredefinedResolution} from './NativeApiVideoLiveStreamView';
export type {
Resolution,
PredefinedResolution,
} from './NativeApiVideoLiveStreamView';

0 comments on commit 5790889

Please sign in to comment.