mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Merge branch '@update/inventory' into @update/friends
This commit is contained in:
commit
86d8ba31f5
@ -3,8 +3,8 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "cross-env BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
|
"start": "cross-env SKIP_PREFLIGHT_CHECK=true BROWSER=none IMAGE_INLINE_SIZE_LIMIT=100000 craco start",
|
||||||
"build": "cross-env GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
|
"build": "cross-env SKIP_PREFLIGHT_CHECK=true GENERATE_SOURCEMAP=false IMAGE_INLINE_SIZE_LIMIT=100000 craco build",
|
||||||
"build:prod": "npx browserslist@latest --update-db && yarn build",
|
"build:prod": "npx browserslist@latest --update-db && yarn build",
|
||||||
"test": "craco test",
|
"test": "craco test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
@ -14,7 +14,7 @@
|
|||||||
"@fortawesome/fontawesome-svg-core": "^6.1.0",
|
"@fortawesome/fontawesome-svg-core": "^6.1.0",
|
||||||
"@fortawesome/free-solid-svg-icons": "^6.1.0",
|
"@fortawesome/free-solid-svg-icons": "^6.1.0",
|
||||||
"@fortawesome/react-fontawesome": "^0.1.17",
|
"@fortawesome/react-fontawesome": "^0.1.17",
|
||||||
"@nitrots/nitro-renderer": "^1.1.20",
|
"@nitrots/nitro-renderer": "^1.1.21",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
@ -1,28 +1,26 @@
|
|||||||
import { LocalizeText, NotificationUtilities } from '..';
|
import { LocalizeText, NotificationUtilities } from '..';
|
||||||
import { TradingNotificationType } from './TradingNotificationType';
|
import { TradingNotificationType } from './TradingNotificationType';
|
||||||
|
|
||||||
export const TradingNotificationMessage = (type: number) =>
|
export const TradingNotificationMessage = (type: number, otherUsername: string = '') =>
|
||||||
{
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case TradingNotificationType.ALERT_SCAM:
|
case TradingNotificationType.ALERT_SCAM:
|
||||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.other_not_offering'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.other_not_offering'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||||
return;
|
return;
|
||||||
case TradingNotificationType.ALERT_OTHER_CANCELLED:
|
case TradingNotificationType.HOTEL_TRADING_DISABLED:
|
||||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
case TradingNotificationType.YOU_NOT_ALLOWED:
|
||||||
return;
|
case TradingNotificationType.THEY_NOT_ALLOWED:
|
||||||
case TradingNotificationType.ALERT_ALREADY_OPEN:
|
case TradingNotificationType.ROOM_DISABLED:
|
||||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.already_open'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
case TradingNotificationType.YOU_OPEN:
|
||||||
return;
|
case TradingNotificationType.THEY_OPEN:
|
||||||
case TradingNotificationType.ALERT_OTHER_DISABLED:
|
NotificationUtilities.simpleAlert(LocalizeText(`inventory.trading.openfail.${ type }`, [ 'otherusername' ], [ otherUsername ]), null, null, null, LocalizeText('inventory.trading.openfail.title'));
|
||||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.others_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
|
||||||
return;
|
return;
|
||||||
case TradingNotificationType.ERROR_WHILE_COMMIT:
|
case TradingNotificationType.ERROR_WHILE_COMMIT:
|
||||||
NotificationUtilities.simpleAlert(`${ LocalizeText('inventory.trading.notification.caption') }, ${ LocalizeText('inventory.trading.notification.commiterror.info') }`, null, null, null, LocalizeText('inventory.trading.notification.title'));
|
NotificationUtilities.simpleAlert(`${ LocalizeText('inventory.trading.notification.caption') }, ${ LocalizeText('inventory.trading.notification.commiterror.info') }`, null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||||
return;
|
return;
|
||||||
case TradingNotificationType.YOU_NOT_ALLOWED:
|
case TradingNotificationType.THEY_CANCELLED:
|
||||||
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.warning.own_account_disabled'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
NotificationUtilities.simpleAlert(LocalizeText('inventory.trading.info.closed'), null, null, null, LocalizeText('inventory.trading.notification.title'));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
export class TradingNotificationType
|
export class TradingNotificationType
|
||||||
{
|
{
|
||||||
public static ALERT_SCAM: number = 0;
|
public static ALERT_SCAM: number = 0;
|
||||||
public static ALERT_OTHER_CANCELLED: number = 1;
|
public static HOTEL_TRADING_DISABLED = 1;
|
||||||
public static ALERT_ALREADY_OPEN: number = 2;
|
public static YOU_NOT_ALLOWED: number = 2;
|
||||||
public static ALERT_OTHER_DISABLED: number = 3;
|
public static THEY_NOT_ALLOWED: number = 4;
|
||||||
public static ERROR_WHILE_COMMIT: number = 4;
|
public static ROOM_DISABLED: number = 6;
|
||||||
public static YOU_NOT_ALLOWED: number = 5;
|
public static YOU_OPEN: number = 7;
|
||||||
|
public static THEY_OPEN: number = 8;
|
||||||
|
public static ERROR_WHILE_COMMIT: number = 9;
|
||||||
|
public static THEY_CANCELLED: number = 10;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ interface InventoryFurnitureViewProps
|
|||||||
export const InventoryFurnitureView: FC<InventoryFurnitureViewProps> = props =>
|
export const InventoryFurnitureView: FC<InventoryFurnitureViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { roomSession = null, roomPreviewer = null } = props;
|
const { roomSession = null, roomPreviewer = null } = props;
|
||||||
const { groupItems = [], selectedItem = null, selectItem = null } = useInventoryFurni();
|
const [ filteredGroupItems, setFilteredGroupItems ] = useState<GroupItem[]>([]);
|
||||||
const [ filteredGroupItems, setFilteredGroupItems ] = useState<GroupItem[]>(groupItems);
|
const { groupItems = [], selectedItem = null, selectItem = null, activate = null, deactivate = null } = useInventoryFurni();
|
||||||
const { getCount = null, resetCategory = null } = useInventoryUnseenTracker();
|
const { getCount = null, resetCategory = null } = useInventoryUnseenTracker();
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
@ -86,6 +86,13 @@ export const InventoryFurnitureView: FC<InventoryFurnitureViewProps> = props =>
|
|||||||
}
|
}
|
||||||
}, [ groupItems, getCount, resetCategory ]);
|
}, [ groupItems, getCount, resetCategory ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
const id = activate();
|
||||||
|
|
||||||
|
return () => deactivate(id);
|
||||||
|
}, [ activate, deactivate ]);
|
||||||
|
|
||||||
if(!groupItems || !groupItems.length) return <InventoryCategoryEmptyView title={ LocalizeText('inventory.empty.title') } desc={ LocalizeText('inventory.empty.desc') } />;
|
if(!groupItems || !groupItems.length) return <InventoryCategoryEmptyView title={ LocalizeText('inventory.empty.title') } desc={ LocalizeText('inventory.empty.desc') } />;
|
||||||
|
|
||||||
const InventoryFurnitureItemView: FC<{ groupItem: GroupItem }> = props =>
|
const InventoryFurnitureItemView: FC<{ groupItem: GroupItem }> = props =>
|
||||||
|
@ -258,17 +258,10 @@ export const useInventoryFurni = () =>
|
|||||||
const { setIsVisible, ...rest } = useBetween(useInventoryFurniState);
|
const { setIsVisible, ...rest } = useBetween(useInventoryFurniState);
|
||||||
const { isVisible = false, activate = null, deactivate = null } = useSharedVisibility();
|
const { isVisible = false, activate = null, deactivate = null } = useSharedVisibility();
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
const id = activate();
|
|
||||||
|
|
||||||
return () => deactivate(id);
|
|
||||||
}, [ activate, deactivate ]);
|
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
setIsVisible(isVisible);
|
setIsVisible(isVisible);
|
||||||
}, [ isVisible, setIsVisible ]);
|
}, [ isVisible, setIsVisible ]);
|
||||||
|
|
||||||
return { ...rest };
|
return { activate, deactivate, ...rest };
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOpenFailedParser, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
|
import { AdvancedMap, TradingAcceptComposer, TradingAcceptEvent, TradingCancelComposer, TradingCloseComposer, TradingCloseEvent, TradingCloseParser, TradingCompletedEvent, TradingConfirmationComposer, TradingConfirmationEvent, TradingListItemEvent, TradingListItemRemoveComposer, TradingNotOpenEvent, TradingOpenComposer, TradingOpenEvent, TradingOpenFailedEvent, TradingOtherNotAllowedEvent, TradingUnacceptComposer, TradingYouAreNotAllowedEvent } from '@nitrots/nitro-renderer';
|
||||||
import { useCallback, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useBetween } from 'use-between';
|
import { useBetween } from 'use-between';
|
||||||
import { useInventoryFurni } from '.';
|
import { useInventoryFurni } from '.';
|
||||||
import { BatchUpdates, UseMessageEventHook } from '..';
|
import { BatchUpdates, UseMessageEventHook } from '..';
|
||||||
@ -13,7 +13,7 @@ const useInventoryTradeState = () =>
|
|||||||
const [ ownUser, setOwnUser ] = useState<TradeUserData>(null);
|
const [ ownUser, setOwnUser ] = useState<TradeUserData>(null);
|
||||||
const [ otherUser, setOtherUser ] = useState<TradeUserData>(null);
|
const [ otherUser, setOtherUser ] = useState<TradeUserData>(null);
|
||||||
const [ tradeState, setTradeState ] = useState(TradeState.TRADING_STATE_READY);
|
const [ tradeState, setTradeState ] = useState(TradeState.TRADING_STATE_READY);
|
||||||
const { groupItems = [], setGroupItems = null } = useInventoryFurni();
|
const { groupItems = [], setGroupItems = null, activate = null, deactivate = null } = useInventoryFurni();
|
||||||
const isTrading = (tradeState >= TradeState.TRADING_STATE_RUNNING);
|
const isTrading = (tradeState >= TradeState.TRADING_STATE_RUNNING);
|
||||||
|
|
||||||
const progressTrade = () =>
|
const progressTrade = () =>
|
||||||
@ -126,7 +126,7 @@ const useInventoryTradeState = () =>
|
|||||||
{
|
{
|
||||||
if(ownUser && (parser.userID !== ownUser.userId))
|
if(ownUser && (parser.userID !== ownUser.userId))
|
||||||
{
|
{
|
||||||
TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_CANCELLED);
|
TradingNotificationMessage(TradingNotificationType.THEY_CANCELLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,9 +294,7 @@ const useInventoryTradeState = () =>
|
|||||||
{
|
{
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
if((parser.reason !== TradingOpenFailedParser.REASON_YOU_ARE_ALREADY_TRADING && (parser.reason !== TradingOpenFailedParser.REASON_OTHER_USER_ALREADY_TRADING))) return;
|
TradingNotificationMessage(parser.reason, parser.otherUserName);
|
||||||
|
|
||||||
TradingNotificationMessage(TradingNotificationType.ALERT_ALREADY_OPEN);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
UseMessageEventHook(TradingOpenFailedEvent, onTradingOpenFailedEvent);
|
UseMessageEventHook(TradingOpenFailedEvent, onTradingOpenFailedEvent);
|
||||||
@ -305,7 +303,7 @@ const useInventoryTradeState = () =>
|
|||||||
{
|
{
|
||||||
const parser = event.getParser();
|
const parser = event.getParser();
|
||||||
|
|
||||||
TradingNotificationMessage(TradingNotificationType.ALERT_OTHER_DISABLED);
|
TradingNotificationMessage(TradingNotificationType.THEY_NOT_ALLOWED);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
UseMessageEventHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent);
|
UseMessageEventHook(TradingOtherNotAllowedEvent, onTradingOtherNotAllowedEvent);
|
||||||
@ -319,6 +317,15 @@ const useInventoryTradeState = () =>
|
|||||||
|
|
||||||
UseMessageEventHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent);
|
UseMessageEventHook(TradingYouAreNotAllowedEvent, onTradingYouAreNotAllowedEvent);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if(tradeState === TradeState.TRADING_STATE_READY) return;
|
||||||
|
|
||||||
|
const id = activate();
|
||||||
|
|
||||||
|
return () => deactivate(id);
|
||||||
|
}, [ tradeState, activate, deactivate ]);
|
||||||
|
|
||||||
return { ownUser, otherUser, tradeState, setTradeState, isTrading, groupItems, progressTrade, removeItem, stopTrading };
|
return { ownUser, otherUser, tradeState, setTradeState, isTrading, groupItems, progressTrade, removeItem, stopTrading };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1426,10 +1426,10 @@
|
|||||||
"@jridgewell/resolve-uri" "^3.0.3"
|
"@jridgewell/resolve-uri" "^3.0.3"
|
||||||
"@jridgewell/sourcemap-codec" "^1.4.10"
|
"@jridgewell/sourcemap-codec" "^1.4.10"
|
||||||
|
|
||||||
"@nitrots/nitro-renderer@^1.1.20":
|
"@nitrots/nitro-renderer@^1.1.21":
|
||||||
version "1.1.20"
|
version "1.1.21"
|
||||||
resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.20.tgz#13fd468028542f777d2c1c7902f2247769ffd98d"
|
resolved "https://registry.yarnpkg.com/@nitrots/nitro-renderer/-/nitro-renderer-1.1.21.tgz#8d527d63510fb4c3003e7d48347cdd50b67bb5b1"
|
||||||
integrity sha512-DVwM4M0Iofsgd94dVPoNmzPbt7YzVG5liupULIe+WHo2vhR8fEyq3E+cdQleXtr/MBODGXTHBrU0yL67YDpIRQ==
|
integrity sha512-futoNgDy+wD1il7gEnKly/VlRdESJZrPkG9m+jDy3bswdpRZ0RAph1XYNpNzkSchpxXib2yuKMME6ePPct/l1A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@pixi/canvas-renderer" "^6.3.0"
|
"@pixi/canvas-renderer" "^6.3.0"
|
||||||
"@pixi/extract" "^6.3.0"
|
"@pixi/extract" "^6.3.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user