mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Merge pull request #241 from simoleo89/fix/wired-bugs
fix(wired): @altitude scale & date-range NaN
This commit is contained in:
@@ -1181,7 +1181,7 @@ export const WiredCreatorToolsView: FC<{}> = () =>
|
|||||||
{ key: '@position_x', value: String(liveState?.positionX ?? 0), editable: canEditInspection },
|
{ key: '@position_x', value: String(liveState?.positionX ?? 0), editable: canEditInspection },
|
||||||
{ key: '@position_y', value: String(liveState?.positionY ?? 0), editable: canEditInspection },
|
{ key: '@position_y', value: String(liveState?.positionY ?? 0), editable: canEditInspection },
|
||||||
{ key: '@rotation', value: String(liveState?.rotation ?? 0), editable: canEditInspection },
|
{ key: '@rotation', value: String(liveState?.rotation ?? 0), editable: canEditInspection },
|
||||||
{ key: '@altitude', value: String(Math.round((liveState?.altitude ?? 0) * 100)), editable: canEditInspection },
|
{ key: '@altitude', value: String(liveState?.altitude ?? 0), editable: canEditInspection },
|
||||||
{ key: '@is_invisible', value: '0' },
|
{ key: '@is_invisible', value: '0' },
|
||||||
...(wallItemOffset ? [ { key: '@wallitem_offset', value: wallItemOffset, editable: canEditInspection } ] : []),
|
...(wallItemOffset ? [ { key: '@wallitem_offset', value: wallItemOffset, editable: canEditInspection } ] : []),
|
||||||
{ key: '@type', value: `${ selectedFurnitureData?.availableForBuildersClub ? 1 : 0 }${ selectedFurnitureData?.availableForBuildersClub ? ' (BC)' : ' (Normal)' }` },
|
{ key: '@type', value: `${ selectedFurnitureData?.availableForBuildersClub ? 1 : 0 }${ selectedFurnitureData?.availableForBuildersClub ? ' (BC)' : ' (Normal)' }` },
|
||||||
@@ -1294,7 +1294,7 @@ export const WiredCreatorToolsView: FC<{}> = () =>
|
|||||||
{ key: '@position_x', value: String(liveState?.positionX ?? 0), editable: canEditSelectedUser },
|
{ key: '@position_x', value: String(liveState?.positionX ?? 0), editable: canEditSelectedUser },
|
||||||
{ key: '@position_y', value: String(liveState?.positionY ?? 0), editable: canEditSelectedUser },
|
{ key: '@position_y', value: String(liveState?.positionY ?? 0), editable: canEditSelectedUser },
|
||||||
{ key: '@direction', value: String(liveState?.direction ?? 0), editable: canEditSelectedUser },
|
{ key: '@direction', value: String(liveState?.direction ?? 0), editable: canEditSelectedUser },
|
||||||
{ key: '@altitude', value: String(Math.round((liveState?.altitude ?? 0) * 100)) },
|
{ key: '@altitude', value: String(liveState?.altitude ?? 0) },
|
||||||
...((Number(selectedUser.favouriteGroupId ?? 0) > 0)
|
...((Number(selectedUser.favouriteGroupId ?? 0) > 0)
|
||||||
? [ { key: '@favourite_group_id', value: String(selectedUser.favouriteGroupId) } ]
|
? [ { key: '@favourite_group_id', value: String(selectedUser.favouriteGroupId) } ]
|
||||||
: []),
|
: []),
|
||||||
|
|||||||
@@ -13,35 +13,34 @@ export const WiredConditionDateRangeView: FC<{}> = props =>
|
|||||||
|
|
||||||
const save = () =>
|
const save = () =>
|
||||||
{
|
{
|
||||||
let startDateMili = 0;
|
|
||||||
let endDateMili = 0;
|
|
||||||
|
|
||||||
const startDateInstance = new Date(startDate);
|
const startDateInstance = new Date(startDate);
|
||||||
const endDateInstance = new Date(endDate);
|
const endDateInstance = new Date(endDate);
|
||||||
|
|
||||||
if(startDateInstance && endDateInstance)
|
// new Date('garbage') is a truthy *Invalid Date*, not null — the old
|
||||||
{
|
// `if(startDateInstance && endDateInstance)` was always true, so an
|
||||||
startDateMili = startDateInstance.getTime() / 1000;
|
// unparseable input wrote NaN as the int param. Guard on getTime().
|
||||||
endDateMili = endDateInstance.getTime() / 1000;
|
const startDateMili = isNaN(startDateInstance.getTime()) ? 0 : Math.floor(startDateInstance.getTime() / 1000);
|
||||||
}
|
const endDateMili = isNaN(endDateInstance.getTime()) ? 0 : Math.floor(endDateInstance.getTime() / 1000);
|
||||||
|
|
||||||
setIntParams([ startDateMili, endDateMili ]);
|
setIntParams([ startDateMili, endDateMili ]);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
|
// Seed both inputs (default "now") even for a never-configured furni so
|
||||||
|
// the first save can't send new Date('') → NaN.
|
||||||
|
let startDate = new Date();
|
||||||
|
let endDate = new Date();
|
||||||
|
|
||||||
if(trigger.intData.length >= 2)
|
if(trigger.intData.length >= 2)
|
||||||
{
|
{
|
||||||
let startDate = new Date();
|
|
||||||
let endDate = new Date();
|
|
||||||
|
|
||||||
if(trigger.intData[0] > 0) startDate = new Date((trigger.intData[0] * 1000));
|
if(trigger.intData[0] > 0) startDate = new Date((trigger.intData[0] * 1000));
|
||||||
|
|
||||||
if(trigger.intData[1] > 0) endDate = new Date((trigger.intData[1] * 1000));
|
if(trigger.intData[1] > 0) endDate = new Date((trigger.intData[1] * 1000));
|
||||||
|
|
||||||
setStartDate(WiredDateToString(startDate));
|
|
||||||
setEndDate(WiredDateToString(endDate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setStartDate(WiredDateToString(startDate));
|
||||||
|
setEndDate(WiredDateToString(endDate));
|
||||||
}, [ trigger ]);
|
}, [ trigger ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user