Skip to content

Commit

Permalink
feat(smartAvatar): ACT-759 refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-wolf3d committed Aug 2, 2024
1 parent 6837c1a commit 5783fa8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/hooks/useDeviceDetector/use-device-detector.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ const TIER_PRESETS: TierPresets = {
};

type DeviceDetectorServiceProps = {
gpuTierResults: TierResult;
gpuTierResult: TierResult;
tierPresets?: TierPresets;
};

class DeviceDetectorService {
private tierPresets: TierPresets = TIER_PRESETS;

private gpuTierResults: TierResult;
private gpuTierResult: TierResult;

constructor(props: DeviceDetectorServiceProps) {
this.gpuTierResults = props.gpuTierResults;
this.gpuTierResult = props.gpuTierResult;
if (props.tierPresets) {
this.tierPresets = props.tierPresets;
}
}

toQueryString() {
return stringify(this.tierPresets[this.gpuTierResults.tier]);
return stringify(this.tierPresets[this.gpuTierResult.tier]);
}
}

Expand All @@ -47,13 +47,13 @@ export function useDeviceDetector(options?: DeviceDetectorHookProps) {

useEffect(() => {
const fetchDeviceDetector = async () => {
const gpuTier = await getGPUTier();
const gpuTierResult = await getGPUTier();

if (gpuTier.type !== 'BENCHMARK') {
gpuTier.tier = 3;
if (gpuTierResult.type !== 'BENCHMARK') {
gpuTierResult.tier = 3;
}

setDeviceDetector(new DeviceDetectorService({ gpuTierResults: gpuTier, tierPresets: options?.tierPresets }));
setDeviceDetector(new DeviceDetectorService({ gpuTierResult, ...options }));
};
fetchDeviceDetector();
}, []);

Check warning on line 59 in src/hooks/useDeviceDetector/use-device-detector.hook.ts

View workflow job for this annotation

GitHub Actions / Linting

React Hook useEffect has a missing dependency: 'options'. Either include it or remove the dependency array. If 'setDeviceDetector' needs the current value of 'options', you can also switch to useReducer instead of useState and read 'options' in the reducer
Expand Down

0 comments on commit 5783fa8

Please sign in to comment.