mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
Type useFurniChooserState builders + drop dead getUserData guard
The two helper functions buildWallItem and buildFloorItem took roomObject as 'any', so 'model.getValue<number>(...)' became an untyped-function-with-type-args error under tsgo (six hits). Typing the param as IRoomObject (the renderer's public interface — model is already typed there) fixes them all at once. The fallback chain for ownerName was guarded by 'sessionDataManager.getUserData ? sessionDataManager.getUserData(ownerId)?.name : null' — SessionDataManager.getUserData() does NOT exist on the renderer (documented in Nitro_Render_V3/CLAUDE.md), so that branch was always dead. Dropping it removes the four tsgo errors and the misleading condition. Net tsgo error count: 90 -> 80.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { GetRoomEngine, GetSessionDataManager, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
import { GetRoomEngine, GetSessionDataManager, IRoomObject, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { GetRoomSession, LocalizeText, RoomObjectItem } from '../../../api';
|
import { GetRoomSession, LocalizeText, RoomObjectItem } from '../../../api';
|
||||||
import { useFurniAddedEvent, useFurniRemovedEvent } from '../engine';
|
import { useFurniAddedEvent, useFurniRemovedEvent } from '../engine';
|
||||||
@@ -11,7 +11,7 @@ const isPetOrBot = (roomObjectType: string): boolean =>
|
|||||||
roomObjectType === 'bot' ||
|
roomObjectType === 'bot' ||
|
||||||
roomObjectType.includes('rentableBot');
|
roomObjectType.includes('rentableBot');
|
||||||
|
|
||||||
const buildWallItem = (roomObject: any): RoomObjectItem | null =>
|
const buildWallItem = (roomObject: IRoomObject): RoomObjectItem | null =>
|
||||||
{
|
{
|
||||||
if(roomObject.id < 0 || isPetOrBot(roomObject.type)) return null;
|
if(roomObject.id < 0 || isPetOrBot(roomObject.type)) return null;
|
||||||
|
|
||||||
@@ -31,14 +31,12 @@ const buildWallItem = (roomObject: any): RoomObjectItem | null =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID) || 0;
|
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID) || 0;
|
||||||
const ownerName = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME) ||
|
const ownerName = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME) || `User_${ ownerId }`;
|
||||||
(sessionDataManager.getUserData ? sessionDataManager.getUserData(ownerId)?.name : null) ||
|
|
||||||
`User_${ownerId}`;
|
|
||||||
|
|
||||||
return new RoomObjectItem(roomObject.id, RoomObjectCategory.WALL, name, ownerId, ownerName, 'furniture');
|
return new RoomObjectItem(roomObject.id, RoomObjectCategory.WALL, name, ownerId, ownerName, 'furniture');
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildFloorItem = (roomObject: any): RoomObjectItem | null =>
|
const buildFloorItem = (roomObject: IRoomObject): RoomObjectItem | null =>
|
||||||
{
|
{
|
||||||
if(roomObject.id < 0 || isPetOrBot(roomObject.type)) return null;
|
if(roomObject.id < 0 || isPetOrBot(roomObject.type)) return null;
|
||||||
|
|
||||||
@@ -51,9 +49,7 @@ const buildFloorItem = (roomObject: any): RoomObjectItem | null =>
|
|||||||
if(furniData && furniData.name.length) name = furniData.name;
|
if(furniData && furniData.name.length) name = furniData.name;
|
||||||
|
|
||||||
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID) || 0;
|
const ownerId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_OWNER_ID) || 0;
|
||||||
const ownerName = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME) ||
|
const ownerName = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_OWNER_NAME) || `User_${ ownerId }`;
|
||||||
(sessionDataManager.getUserData ? sessionDataManager.getUserData(ownerId)?.name : null) ||
|
|
||||||
`User_${ownerId}`;
|
|
||||||
|
|
||||||
return new RoomObjectItem(roomObject.id, RoomObjectCategory.FLOOR, name, ownerId, ownerName, 'furniture');
|
return new RoomObjectItem(roomObject.id, RoomObjectCategory.FLOOR, name, ownerId, ownerName, 'furniture');
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user