From 9a55b570221f19894554974074c20908dad2f4dc Mon Sep 17 00:00:00 2001 From: MyNameIsBatman Date: Wed, 30 Jun 2021 13:05:10 -0300 Subject: [PATCH] Eslint Fixes --- src/views/avatar-editor/AvatarEditorView.tsx | 1 - .../creator/NavigatorRoomCreatorView.tsx | 5 +- .../NotificationCenterView.tsx | 2 +- .../room/widgets/camera/CameraWidgetView.tsx | 2 +- .../views/capture/CameraWidgetCaptureView.tsx | 4 +- .../checkout/CameraWidgetCheckoutView.tsx | 9 +- .../views/editor/CameraWidgetEditorView.tsx | 8 +- .../mannequin/FurnitureMannequinView.tsx | 120 +++++++++--------- 8 files changed, 76 insertions(+), 75 deletions(-) diff --git a/src/views/avatar-editor/AvatarEditorView.tsx b/src/views/avatar-editor/AvatarEditorView.tsx index fff21b3d..0e19abaf 100644 --- a/src/views/avatar-editor/AvatarEditorView.tsx +++ b/src/views/avatar-editor/AvatarEditorView.tsx @@ -11,7 +11,6 @@ export const AvatarEditorView: FC = props => { const [ isVisible, setIsVisible ] = useState(false); const [ avatarEditorState, dispatchAvatarEditorState ] = useReducer(AvatarEditorReducer, initialAvatarEditor); - const { } = avatarEditorState; const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) => { diff --git a/src/views/navigator/views/creator/NavigatorRoomCreatorView.tsx b/src/views/navigator/views/creator/NavigatorRoomCreatorView.tsx index e82d1a79..9698ccf1 100644 --- a/src/views/navigator/views/creator/NavigatorRoomCreatorView.tsx +++ b/src/views/navigator/views/creator/NavigatorRoomCreatorView.tsx @@ -1,3 +1,4 @@ +/* eslint-disable no-template-curly-in-string */ import classNames from 'classnames'; import { HabboClubLevelEnum, RoomCreateComposer } from 'nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; @@ -35,7 +36,7 @@ export const NavigatorRoomCreatorView: FC = props setMaxVisitorsList(list); setVisitorsCount(list[0]); } - }, []); + }, [ maxVisitorsList ]); useEffect(() => { @@ -116,7 +117,7 @@ export const NavigatorRoomCreatorView: FC = props NAVIGATOR_ROOM_MODELS.map(model => { return (
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}) }> - +
{ model.tileSize } { LocalizeText('navigator.createroom.tilesize') }
{ model.clubLevel > HabboClubLevelEnum.NO_CLUB && }
); diff --git a/src/views/notification-center/NotificationCenterView.tsx b/src/views/notification-center/NotificationCenterView.tsx index 61367339..de872df3 100644 --- a/src/views/notification-center/NotificationCenterView.tsx +++ b/src/views/notification-center/NotificationCenterView.tsx @@ -79,7 +79,7 @@ export const NotificationCenterView: FC = props => }); return; } - }, [ notificationCenterState, dispatchNotificationCenterState ]); + }, [ dispatchNotificationCenterState ]); const mapNotifications = useCallback((notifications: NitroNotification[], inTray: boolean) => { diff --git a/src/views/room/widgets/camera/CameraWidgetView.tsx b/src/views/room/widgets/camera/CameraWidgetView.tsx index a93e5006..23d083a1 100644 --- a/src/views/room/widgets/camera/CameraWidgetView.tsx +++ b/src/views/room/widgets/camera/CameraWidgetView.tsx @@ -64,7 +64,7 @@ export const CameraWidgetView: FC = props => const parser = event.getParser(); setPrice({ credits: parser.credits, points: parser.points, pointsType: parser.pointsType }); - }, [ price ]); + }, []); CreateMessageHook(RoomWidgetCameraConfigurationEvent, onCameraConfigurationEvent); diff --git a/src/views/room/widgets/camera/views/capture/CameraWidgetCaptureView.tsx b/src/views/room/widgets/camera/views/capture/CameraWidgetCaptureView.tsx index d05d6698..733a1eb4 100644 --- a/src/views/room/widgets/camera/views/capture/CameraWidgetCaptureView.tsx +++ b/src/views/room/widgets/camera/views/capture/CameraWidgetCaptureView.tsx @@ -83,7 +83,7 @@ export const CameraWidgetCaptureView: FC = props =
-1}) }> { cameraWidgetContext.selectedPictureIndex > -1 &&
- +
@@ -97,7 +97,7 @@ export const CameraWidgetCaptureView: FC = props = { cameraWidgetContext.cameraRoll.length > 0 &&
{ cameraWidgetContext.cameraRoll.map((picture, index) => { - return processAction('preview_picture', index) } />; + return processAction('preview_picture', index) } />; }) }
}
diff --git a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx index 11597267..21b4727c 100644 --- a/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx +++ b/src/views/room/widgets/camera/views/checkout/CameraWidgetCheckoutView.tsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ import { RoomWidgetCameraPublishComposer, RoomWidgetCameraPublishedEvent, RoomWidgetCameraPurchaseComposer, RoomWidgetCameraPurchaseSuccessfulEvent } from 'nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { GetRoomCameraWidgetManager } from '../../../../../../api/nitro/camera/GetRoomCameraWidgetManager'; @@ -23,7 +24,7 @@ export const CameraWidgetCheckoutView: FC = props { setPicturesBought(value => value + 1); setIsWaiting(false); - }, [ picturesBought ]); + }, []); const onRoomWidgetCameraPublishedEvent = useCallback((event: RoomWidgetCameraPublishedEvent) => { @@ -32,7 +33,7 @@ export const CameraWidgetCheckoutView: FC = props setPublishCooldown(parser.cooldownSeconds); setWasPicturePublished(parser.wasSuccessful); setIsWaiting(false); - }, [ wasPicturePublished, publishCooldown ]); + }, []); CreateMessageHook(RoomWidgetCameraPurchaseSuccessfulEvent, onCameraPurchaseSuccessfulEvent); CreateMessageHook(RoomWidgetCameraPublishedEvent, onRoomWidgetCameraPublishedEvent); @@ -40,7 +41,7 @@ export const CameraWidgetCheckoutView: FC = props const getCurrentPicture = useCallback(() => { 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) => { @@ -65,7 +66,7 @@ export const CameraWidgetCheckoutView: FC = props onCancelClick(); return; } - }, [ onCloseClick, onCancelClick ]); + }, [onCloseClick, isWaiting, onCancelClick]); if(!price) return null; diff --git a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx index c436d4f3..b079dd9f 100644 --- a/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx +++ b/src/views/room/widgets/camera/views/editor/CameraWidgetEditorView.tsx @@ -29,7 +29,7 @@ export const CameraWidgetEditorView: FC = props => } setEffectsThumbnails(thumbnails); - }, [ cameraWidgetContext.selectedPictureIndex, availableEffects ]); + }, [ cameraWidgetContext, availableEffects ]); const getEffectThumbnail = useCallback((effectName: string) => { @@ -55,7 +55,7 @@ export const CameraWidgetEditorView: FC = props => const getCurrentPicture = useCallback(() => { return GetRoomCameraWidgetManager().applyEffects(cameraWidgetContext.cameraRoll[cameraWidgetContext.selectedPictureIndex], cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed); - }, [ cameraWidgetContext.selectedEffects, cameraWidgetContext.isZoomed ]); + }, [ cameraWidgetContext ]); const getCurrentEffectAlpha = useCallback(() => { @@ -88,7 +88,7 @@ export const CameraWidgetEditorView: FC = props => clone[selectedEffectIndex] = new RoomCameraWidgetSelectedEffect(selectedEffect.effect, newAlpha); cameraWidgetContext.setSelectedEffects(clone); - }, [ selectedEffectName, cameraWidgetContext.selectedEffects ]); + }, [ selectedEffectName, getEffectIndex, cameraWidgetContext ]); const processAction = useCallback((type: string, value: string | number = null) => { @@ -169,7 +169,7 @@ export const CameraWidgetEditorView: FC = props => cameraWidgetContext.setIsZoomed(!cameraWidgetContext.isZoomed); return; } - }, [ onCloseClick, onCancelClick, availableEffects, cameraWidgetContext.selectedEffects, selectedEffectName ]); + }, [onCloseClick, onCancelClick, onCheckoutClick, cameraWidgetContext, getCurrentPicture, myLevel, selectedEffectName, getEffectIndex, availableEffects]); return ( diff --git a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx index 87fc9f2f..d2c762ba 100644 --- a/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx +++ b/src/views/room/widgets/furniture/mannequin/FurnitureMannequinView.tsx @@ -13,23 +13,38 @@ import { RoomWidgetRoomObjectUpdateEvent } from '../../../events'; import { FurnitureMannequinData } from './FurnitureMannequinData'; import { FurnitureMannequinViewMode, FurnitureMannequinViewProps } from './FurnitureMannequinView.types'; +const parts = [ + AvatarFigurePartType.CHEST_ACCESSORY, + AvatarFigurePartType.COAT_CHEST, + AvatarFigurePartType.CHEST, + AvatarFigurePartType.LEGS, + AvatarFigurePartType.SHOES, + AvatarFigurePartType.WAIST_ACCESSORY +]; +const baseAvatar = ['hd', 99999, 99998]; + export const FurnitureMannequinView: FC = props => { - const { eventDispatcher = null, widgetHandler = null } = useRoomContext(); - - const parts = [ - AvatarFigurePartType.CHEST_ACCESSORY, - AvatarFigurePartType.COAT_CHEST, - AvatarFigurePartType.CHEST, - AvatarFigurePartType.LEGS, - AvatarFigurePartType.SHOES, - AvatarFigurePartType.WAIST_ACCESSORY - ]; - const baseAvatar = ['hd', 99999, 99998]; + const { eventDispatcher = null } = useRoomContext(); const [ mannequinData, setMannequinData ] = useState(null); 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(() => { if(mannequinData && !mannequinData.renderedFigure) @@ -37,7 +52,38 @@ export const FurnitureMannequinView: FC = props => const figureContainer = Nitro.instance.avatar.createFigureContainer(mannequinData.figure); 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) => { @@ -75,57 +121,11 @@ export const FurnitureMannequinView: FC = props => return; } } - }, []); + }, [loadViewMode]); useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN, 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) => { switch(type) @@ -157,7 +157,7 @@ export const FurnitureMannequinView: FC = props => processAction('close'); return; } - }, [ mannequinData ]); + }, [ loadMannequinFigure, mannequinData ]); const handleKeyDown = (event: KeyboardEvent) => {