Eslint Fixes

This commit is contained in:
MyNameIsBatman 2021-06-30 13:05:10 -03:00
parent d14117d70a
commit 9a55b57022
8 changed files with 76 additions and 75 deletions

View File

@ -11,7 +11,6 @@ export const AvatarEditorView: FC<AvatarEditorViewProps> = props =>
{ {
const [ isVisible, setIsVisible ] = useState(false); const [ isVisible, setIsVisible ] = useState(false);
const [ avatarEditorState, dispatchAvatarEditorState ] = useReducer(AvatarEditorReducer, initialAvatarEditor); const [ avatarEditorState, dispatchAvatarEditorState ] = useReducer(AvatarEditorReducer, initialAvatarEditor);
const { } = avatarEditorState;
const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) => const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) =>
{ {

View File

@ -1,3 +1,4 @@
/* eslint-disable no-template-curly-in-string */
import classNames from 'classnames'; import classNames from 'classnames';
import { HabboClubLevelEnum, RoomCreateComposer } from 'nitro-renderer'; import { HabboClubLevelEnum, RoomCreateComposer } from 'nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
@ -35,7 +36,7 @@ export const NavigatorRoomCreatorView: FC<NavigatorRoomCreatorViewProps> = props
setMaxVisitorsList(list); setMaxVisitorsList(list);
setVisitorsCount(list[0]); setVisitorsCount(list[0]);
} }
}, []); }, [ maxVisitorsList ]);
useEffect(() => useEffect(() =>
{ {
@ -116,7 +117,7 @@ export const NavigatorRoomCreatorView: FC<NavigatorRoomCreatorViewProps> = props
NAVIGATOR_ROOM_MODELS.map(model => NAVIGATOR_ROOM_MODELS.map(model =>
{ {
return (<div key={ model.name } onClick={ () => selectModel(model.name) } className={ 'h-100 cursor-pointer d-flex flex-column justify-content-center align-items-center p-1 me-2 rounded border border-2' + classNames({' active': selectedModelName === model.name, ' disabled': GetSessionDataManager().clubLevel < model.clubLevel}) }> return (<div key={ model.name } onClick={ () => selectModel(model.name) } className={ 'h-100 cursor-pointer d-flex flex-column justify-content-center align-items-center p-1 me-2 rounded border border-2' + classNames({' active': selectedModelName === model.name, ' disabled': GetSessionDataManager().clubLevel < model.clubLevel}) }>
<img src={ getRoomModelImage(model.name) } /> <img alt="" src={ getRoomModelImage(model.name) } />
<div>{ model.tileSize } { LocalizeText('navigator.createroom.tilesize') }</div> <div>{ model.tileSize } { LocalizeText('navigator.createroom.tilesize') }</div>
{ model.clubLevel > HabboClubLevelEnum.NO_CLUB && <CurrencyIcon type="hc" /> } { model.clubLevel > HabboClubLevelEnum.NO_CLUB && <CurrencyIcon type="hc" /> }
</div>); </div>);

View File

@ -79,7 +79,7 @@ export const NotificationCenterView: FC<NotificationCenterViewProps> = props =>
}); });
return; return;
} }
}, [ notificationCenterState, dispatchNotificationCenterState ]); }, [ dispatchNotificationCenterState ]);
const mapNotifications = useCallback((notifications: NitroNotification[], inTray: boolean) => const mapNotifications = useCallback((notifications: NitroNotification[], inTray: boolean) =>
{ {

View File

@ -64,7 +64,7 @@ export const CameraWidgetView: FC<CameraWidgetViewProps> = props =>
const parser = event.getParser(); const parser = event.getParser();
setPrice({ credits: parser.credits, points: parser.points, pointsType: parser.pointsType }); setPrice({ credits: parser.credits, points: parser.points, pointsType: parser.pointsType });
}, [ price ]); }, []);
CreateMessageHook(RoomWidgetCameraConfigurationEvent, onCameraConfigurationEvent); CreateMessageHook(RoomWidgetCameraConfigurationEvent, onCameraConfigurationEvent);

View File

@ -83,7 +83,7 @@ export const CameraWidgetCaptureView: FC<CameraWidgetCaptureViewProps> = props =
</div> </div>
<div ref={ cameraFrameRef } className={'camera-frame ' + classNames({'bg': cameraWidgetContext.selectedPictureIndex > -1}) }> <div ref={ cameraFrameRef } className={'camera-frame ' + classNames({'bg': cameraWidgetContext.selectedPictureIndex > -1}) }>
{ cameraWidgetContext.selectedPictureIndex > -1 && <div> { cameraWidgetContext.selectedPictureIndex > -1 && <div>
<img src={ cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex].src } /> <img alt="" src={ cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex].src } />
<div className="camera-frame-preview-actions w-100 position-absolute bottom-0 py-2 text-center"> <div className="camera-frame-preview-actions w-100 position-absolute bottom-0 py-2 text-center">
<button className="btn btn-success me-3" title={ LocalizeText('camera.editor.button.tooltip') } onClick={ event => processAction('edit_picture') }>{ LocalizeText('camera.editor.button.text') }</button> <button className="btn btn-success me-3" title={ LocalizeText('camera.editor.button.tooltip') } onClick={ event => processAction('edit_picture') }>{ LocalizeText('camera.editor.button.text') }</button>
<button className="btn btn-danger" onClick={ event => processAction('discard_picture') }>{ LocalizeText('camera.delete.button.text') }</button> <button className="btn btn-danger" onClick={ event => processAction('discard_picture') }>{ LocalizeText('camera.delete.button.text') }</button>
@ -97,7 +97,7 @@ export const CameraWidgetCaptureView: FC<CameraWidgetCaptureViewProps> = props =
{ cameraWidgetContext.cameraRoll.length > 0 && <div className="camera-roll d-flex justify-content-center py-2"> { cameraWidgetContext.cameraRoll.length > 0 && <div className="camera-roll d-flex justify-content-center py-2">
{ cameraWidgetContext.cameraRoll.map((picture, index) => { cameraWidgetContext.cameraRoll.map((picture, index) =>
{ {
return <img key={ index } className={ (index < cameraWidgetContext.cameraRoll.length - 1 ? 'me-2' : '') } src={ picture.src } onClick={ event => processAction('preview_picture', index) } />; return <img alt="" key={ index } className={ (index < cameraWidgetContext.cameraRoll.length - 1 ? 'me-2' : '') } src={ picture.src } onClick={ event => processAction('preview_picture', index) } />;
}) } }) }
</div> } </div> }
</div> </div>

View File

@ -1,3 +1,4 @@
/* eslint-disable jsx-a11y/anchor-is-valid */
import { RoomWidgetCameraPublishComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, RoomWidgetCameraPurchaseSuccessfulEvent } from 'nitro-renderer'; import { RoomWidgetCameraPublishComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, RoomWidgetCameraPurchaseSuccessfulEvent } from 'nitro-renderer';
import { FC, useCallback, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { GetRoomCameraWidgetManager } from '../../../../../../api/nitro/camera/GetRoomCameraWidgetManager'; import { GetRoomCameraWidgetManager } from '../../../../../../api/nitro/camera/GetRoomCameraWidgetManager';
@ -23,7 +24,7 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
{ {
setPicturesBought(value => value + 1); setPicturesBought(value => value + 1);
setIsWaiting(false); setIsWaiting(false);
}, [ picturesBought ]); }, []);
const onRoomWidgetCameraPublishedEvent = useCallback((event: RoomWidgetCameraPublishedEvent) => const onRoomWidgetCameraPublishedEvent = useCallback((event: RoomWidgetCameraPublishedEvent) =>
{ {
@ -32,7 +33,7 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
setPublishCooldown(parser.cooldownSeconds); setPublishCooldown(parser.cooldownSeconds);
setWasPicturePublished(parser.wasSuccessful); setWasPicturePublished(parser.wasSuccessful);
setIsWaiting(false); setIsWaiting(false);
}, [ wasPicturePublished, publishCooldown ]); }, []);
CreateMessageHook(RoomWidgetCameraPurchaseSuccessfulEvent, onCameraPurchaseSuccessfulEvent); CreateMessageHook(RoomWidgetCameraPurchaseSuccessfulEvent, onCameraPurchaseSuccessfulEvent);
CreateMessageHook(RoomWidgetCameraPublishedEvent, onRoomWidgetCameraPublishedEvent); CreateMessageHook(RoomWidgetCameraPublishedEvent, onRoomWidgetCameraPublishedEvent);
@ -40,7 +41,7 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
const getCurrentPicture = useCallback(() => const getCurrentPicture = useCallback(() =>
{ {
return GetRoomCameraWidgetManager().applyEffects(cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex], cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed); return GetRoomCameraWidgetManager().applyEffects(cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex], cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed);
}, [ cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed ]); }, [ cameraWidgetContext ]);
const processAction = useCallback((type: string, value: string | number = null) => const processAction = useCallback((type: string, value: string | number = null) =>
{ {
@ -65,7 +66,7 @@ export const CameraWidgetCheckoutView: FC<CameraWidgetCheckoutViewProps> = props
onCancelClick(); onCancelClick();
return; return;
} }
}, [ onCloseClick, onCancelClick ]); }, [onCloseClick, isWaiting, onCancelClick]);
if(!price) return null; if(!price) return null;

View File

@ -29,7 +29,7 @@ export const CameraWidgetEditorView: FC<CameraWidgetEditorViewProps> = props =>
} }
setEffectsThumbnails(thumbnails); setEffectsThumbnails(thumbnails);
}, [ cameraWidgetContext.selectedPictureIndex, availableEffects ]); }, [ cameraWidgetContext, availableEffects ]);
const getEffectThumbnail = useCallback((effectName: string) => const getEffectThumbnail = useCallback((effectName: string) =>
{ {
@ -55,7 +55,7 @@ export const CameraWidgetEditorView: FC<CameraWidgetEditorViewProps> = props =>
const getCurrentPicture = useCallback(() => const getCurrentPicture = useCallback(() =>
{ {
return GetRoomCameraWidgetManager().applyEffects(cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex], cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed); return GetRoomCameraWidgetManager().applyEffects(cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex], cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed);
}, [ cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed ]); }, [ cameraWidgetContext ]);
const getCurrentEffectAlpha = useCallback(() => const getCurrentEffectAlpha = useCallback(() =>
{ {
@ -88,7 +88,7 @@ export const CameraWidgetEditorView: FC<CameraWidgetEditorViewProps> = props =>
clone[selectedEffectIndex] = new RoomCameraWidgetSelectedEffect(selectedEffect.effect, newAlpha); clone[selectedEffectIndex] = new RoomCameraWidgetSelectedEffect(selectedEffect.effect, newAlpha);
cameraWidgetContext.setSelectedEffects(clone); cameraWidgetContext.setSelectedEffects(clone);
}, [ selectedEffectName, cameraWidgetContext.selectedEffects ]); }, [ selectedEffectName, getEffectIndex, cameraWidgetContext ]);
const processAction = useCallback((type: string, value: string | number = null) => const processAction = useCallback((type: string, value: string | number = null) =>
{ {
@ -169,7 +169,7 @@ export const CameraWidgetEditorView: FC<CameraWidgetEditorViewProps> = props =>
cameraWidgetContext.setIsZoomed(!cameraWidgetContext.isZoomed); cameraWidgetContext.setIsZoomed(!cameraWidgetContext.isZoomed);
return; return;
} }
}, [ onCloseClick, onCancelClick, availableEffects, cameraWidgetContext.selectedEffects, selectedEffectName ]); }, [onCloseClick, onCancelClick, onCheckoutClick, cameraWidgetContext, getCurrentPicture, myLevel, selectedEffectName, getEffectIndex, availableEffects]);
return ( return (
<NitroCardView className="nitro-camera-editor"> <NitroCardView className="nitro-camera-editor">

View File

@ -13,23 +13,38 @@ import { RoomWidgetRoomObjectUpdateEvent } from '../../../events';
import { FurnitureMannequinData } from './FurnitureMannequinData'; import { FurnitureMannequinData } from './FurnitureMannequinData';
import { FurnitureMannequinViewMode, FurnitureMannequinViewProps } from './FurnitureMannequinView.types'; import { FurnitureMannequinViewMode, FurnitureMannequinViewProps } from './FurnitureMannequinView.types';
export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props => const parts = [
{
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
const parts = [
AvatarFigurePartType.CHEST_ACCESSORY, AvatarFigurePartType.CHEST_ACCESSORY,
AvatarFigurePartType.COAT_CHEST, AvatarFigurePartType.COAT_CHEST,
AvatarFigurePartType.CHEST, AvatarFigurePartType.CHEST,
AvatarFigurePartType.LEGS, AvatarFigurePartType.LEGS,
AvatarFigurePartType.SHOES, AvatarFigurePartType.SHOES,
AvatarFigurePartType.WAIST_ACCESSORY AvatarFigurePartType.WAIST_ACCESSORY
]; ];
const baseAvatar = ['hd', 99999, 99998]; const baseAvatar = ['hd', 99999, 99998];
export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
{
const { eventDispatcher = null } = useRoomContext();
const [ mannequinData, setMannequinData ] = useState<FurnitureMannequinData>(null); const [ mannequinData, setMannequinData ] = useState<FurnitureMannequinData>(null);
const [ viewMode, setViewMode ] = useState(''); const [ viewMode, setViewMode ] = useState('');
const loadMannequinFigure = useCallback((figureContainer: IAvatarFigureContainer) =>
{
for(const item of figureContainer.getPartTypeIds())
{
if(parts.indexOf(item) === -1)
{
figureContainer.removePart(item);
}
}
figureContainer.updatePart(baseAvatar[0].toString(), Number(baseAvatar[1]), [ Number(baseAvatar[2]) ]);
setMannequinData(mannequinData => new FurnitureMannequinData(mannequinData.objectId, mannequinData.category, mannequinData.name, mannequinData.figure, mannequinData.gender, mannequinData.clubLevel, figureContainer.getFigureString()));
}, []);
useEffect(() => useEffect(() =>
{ {
if(mannequinData && !mannequinData.renderedFigure) if(mannequinData && !mannequinData.renderedFigure)
@ -37,7 +52,38 @@ export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
const figureContainer = Nitro.instance.avatar.createFigureContainer(mannequinData.figure); const figureContainer = Nitro.instance.avatar.createFigureContainer(mannequinData.figure);
loadMannequinFigure(figureContainer); loadMannequinFigure(figureContainer);
} }
}, [ mannequinData ]); }, [loadMannequinFigure, mannequinData]);
const loadViewMode = useCallback((mannequinData: FurnitureMannequinData) =>
{
if(!mannequinData) return;
const userCanEdit = (GetRoomSession().isRoomOwner || GetSessionDataManager().isModerator);
const userGender = Nitro.instance.sessionDataManager.gender;
const userClubLevel = Nitro.instance.sessionDataManager.clubLevel;
if(userCanEdit)
{
setViewMode(FurnitureMannequinViewMode.EDIT);
}
else
{
if(!mannequinData.figure || mannequinData.figure.length <= 1) return;
if(userGender.toUpperCase() !== mannequinData.gender.toUpperCase())
{
setViewMode(FurnitureMannequinViewMode.INCOMPATIBLE_GENDER);
}
else if(userClubLevel < mannequinData.clubLevel)
{
setViewMode(FurnitureMannequinViewMode.CLUB);
}
else
{
setViewMode(FurnitureMannequinViewMode.DEFAULT);
}
}
}, []);
const onNitroEvent = useCallback((event: NitroEvent) => const onNitroEvent = useCallback((event: NitroEvent) =>
{ {
@ -75,57 +121,11 @@ export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
return; return;
} }
} }
}, []); }, [loadViewMode]);
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onNitroEvent); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent); CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, eventDispatcher, onNitroEvent);
const loadMannequinFigure = useCallback((figureContainer: IAvatarFigureContainer) =>
{
for(const item of figureContainer.getPartTypeIds())
{
if(parts.indexOf(item) === -1)
{
figureContainer.removePart(item);
}
}
figureContainer.updatePart(baseAvatar[0].toString(), Number(baseAvatar[1]), [ Number(baseAvatar[2]) ]);
setMannequinData(mannequinData => new FurnitureMannequinData(mannequinData.objectId, mannequinData.category, mannequinData.name, mannequinData.figure, mannequinData.gender, mannequinData.clubLevel, figureContainer.getFigureString()));
}, []);
const loadViewMode = useCallback((mannequinData: FurnitureMannequinData) =>
{
if(!mannequinData) return;
const userCanEdit = (GetRoomSession().isRoomOwner || GetSessionDataManager().isModerator);
const userGender = Nitro.instance.sessionDataManager.gender;
const userClubLevel = Nitro.instance.sessionDataManager.clubLevel;
if(userCanEdit)
{
setViewMode(FurnitureMannequinViewMode.EDIT);
}
else
{
if(!mannequinData.figure || mannequinData.figure.length <= 1) return;
if(userGender.toUpperCase() !== mannequinData.gender.toUpperCase())
{
setViewMode(FurnitureMannequinViewMode.INCOMPATIBLE_GENDER);
}
else if(userClubLevel < mannequinData.clubLevel)
{
setViewMode(FurnitureMannequinViewMode.CLUB);
}
else
{
setViewMode(FurnitureMannequinViewMode.DEFAULT);
}
}
}, []);
const processAction = useCallback((type: string, value: string = null) => const processAction = useCallback((type: string, value: string = null) =>
{ {
switch(type) switch(type)
@ -157,7 +157,7 @@ export const FurnitureMannequinView: FC<FurnitureMannequinViewProps> = props =>
processAction('close'); processAction('close');
return; return;
} }
}, [ mannequinData ]); }, [ loadMannequinFigure, mannequinData ]);
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) =>
{ {