From 56daa2bbe6c4fb441f284401902a163f83aef511 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 29 Apr 2021 04:03:16 -0400 Subject: [PATCH] Update furniture inventory --- .../reducers/InventoryFurnitureReducer.tsx | 20 ++++---- .../inventory/utils/FurnitureUtilities.ts | 48 +++++-------------- .../furniture/InventoryFurnitureView.tsx | 19 +++++++- .../item/InventoryFurnitureItemView.tsx | 4 +- .../InventoryFurnitureResultsView.scss | 2 +- .../results/InventoryFurnitureResultsView.tsx | 2 +- 6 files changed, 43 insertions(+), 52 deletions(-) diff --git a/src/views/inventory/reducers/InventoryFurnitureReducer.tsx b/src/views/inventory/reducers/InventoryFurnitureReducer.tsx index dd1f146a..9ef8e67a 100644 --- a/src/views/inventory/reducers/InventoryFurnitureReducer.tsx +++ b/src/views/inventory/reducers/InventoryFurnitureReducer.tsx @@ -1,7 +1,7 @@ import { FurnitureListItemParser } from 'nitro-renderer'; import { Reducer } from 'react'; import { FurnitureItem } from '../utils/FurnitureItem'; -import { addFurnitureItem, processFragment, removeItemById } from '../utils/FurnitureUtilities'; +import { addFurnitureItem, processFurniFragment, removeFurniItemById } from '../utils/FurnitureUtilities'; import { GroupItem } from '../utils/GroupItem'; export interface IInventoryFurnitureState @@ -27,9 +27,9 @@ export class InventoryFurnitureActions { public static SET_NEEDS_UPDATE: string = 'IFA_SET_NEEDS_UPDATE'; public static SET_GROUP_ITEM: string = 'IFA_SET_GROUP_ITEM'; + public static PROCESS_FRAGMENT: string = 'IFA_PROCESS_FRAGMENT'; public static ADD_OR_UPDATE_FURNITURE: string = 'IFA_ADD_OR_UPDATE_FURNITURE'; public static REMOVE_FURNITURE: string = 'IFA_REMOVE_FURNITURE'; - public static PROCESS_FRAGMENT: string = 'IFA_PROCESS_FRAGMENT'; } export const initialInventoryFurniture: IInventoryFurnitureState = { @@ -60,6 +60,13 @@ export const inventoryFurnitureReducer: Reducer, totalFragments: number, fragmentNumber: number, fragments: Map[]) +export function mergeFurniFragments(fragment: Map, totalFragments: number, fragmentNumber: number, fragments: Map[]) { if(totalFragments === 1) return fragment; @@ -120,7 +98,7 @@ export function mergeFragments(fragment: Map, t return merged; } -export function getAllItemIds(groupItems: GroupItem[]): number[] +function getAllItemIds(groupItems: GroupItem[]): number[] { const itemIds: number[] = []; @@ -143,7 +121,7 @@ export function getAllItemIds(groupItems: GroupItem[]): number[] return itemIds; } -export function processFragment(set: GroupItem[], fragment: Map): GroupItem[] +export function processFurniFragment(set: GroupItem[], fragment: Map): GroupItem[] { const existingIds = getAllItemIds(set); const addedIds: number[] = []; @@ -155,7 +133,7 @@ export function processFragment(set: GroupItem[], fragment: Map = props => { const { roomSession = null, roomPreviewer = null } = props; - const { furnitureState = null, dispatchFurnitureState = null } = useInventoryContext(); const { needsFurniUpdate = false, groupItem = null, groupItems = [] } = furnitureState; - const [ filteredGroupItems, setFilteredGroupItems ] = useState(groupItems); useEffect(() => @@ -99,6 +97,23 @@ export const InventoryFurnitureView: FC = props => } }, [ roomPreviewer, groupItem ]); + if(!groupItems || !groupItems.length) + { + return ( +
+
+
+
+
+
+ { LocalizeText('inventory.empty.title') } +
+
{ LocalizeText('inventory.empty.desc') }
+
+
+ ); + } + return (
diff --git a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx b/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx index 8d5399a6..f1179c9c 100644 --- a/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx +++ b/src/views/inventory/views/furniture/item/InventoryFurnitureItemView.tsx @@ -19,9 +19,7 @@ export const InventoryFurnitureItemView: FC = p case MouseEventType.MOUSE_DOWN: dispatchFurnitureState({ type: InventoryFurnitureActions.SET_GROUP_ITEM, - payload: { - groupItem - } + payload: { groupItem } }); setMouseDown(true); diff --git a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss index 17e73328..6f7e0f0b 100644 --- a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss +++ b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.scss @@ -1,4 +1,4 @@ -.item-container { +.furni-item-container { height: 192px; max-height: 192px; overflow-y: auto; diff --git a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx index b92d4d09..628e214a 100644 --- a/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx +++ b/src/views/inventory/views/furniture/results/InventoryFurnitureResultsView.tsx @@ -7,7 +7,7 @@ export const InventoryFurnitureResultsView: FC +
{ (groupItems && groupItems.length && groupItems.map((item, index) => { return