From 9beebe58ba4dfd3fc74e9636633ab9a839de7008 Mon Sep 17 00:00:00 2001 From: brenoepics <59066707+brenoepics@users.noreply.github.com> Date: Tue, 15 Mar 2022 23:52:25 -0300 Subject: [PATCH 1/4] Fix calendar --- src/components/campaign/CalendarItemView.tsx | 11 +++---- src/components/campaign/CalendarView.tsx | 5 ++-- src/components/campaign/CampaignView.tsx | 5 ++-- .../campaign/common/CalendarItem.ts | 30 +++++++++++++++++++ .../campaign/common/ICalendarItem.ts | 6 ++++ 5 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 src/components/campaign/common/CalendarItem.ts create mode 100644 src/components/campaign/common/ICalendarItem.ts diff --git a/src/components/campaign/CalendarItemView.tsx b/src/components/campaign/CalendarItemView.tsx index bd61d3e7..7ca4cb66 100644 --- a/src/components/campaign/CalendarItemView.tsx +++ b/src/components/campaign/CalendarItemView.tsx @@ -1,6 +1,7 @@ import { FC } from 'react'; -import { GetRoomEngine, GetSessionDataManager } from '../../api'; +import { GetConfiguration, GetRoomEngine, GetSessionDataManager } from '../../api'; import { Base, Column, Flex, LayoutImage } from '../../common'; +import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; interface CalendarItemViewProps @@ -8,13 +9,13 @@ interface CalendarItemViewProps itemId: number; state: number; active?: boolean; - productName?: string; + product?: CalendarItem; onClick: (itemId: number) => void; } export const CalendarItemView: FC = props => { - const { itemId = -1, state = null, productName = null, active = false, onClick = null } = props; + const { itemId = -1, state = null, product = null, active = false, onClick = null } = props; const getFurnitureIcon = (name: string) => { @@ -37,8 +38,8 @@ export const CalendarItemView: FC = props => { (state === CalendarItemState.STATE_UNLOCKED) && - { productName && - } + { product && + ('image.library.url') + product.customImage : getFurnitureIcon(product.productName) } /> } } { (state !== CalendarItemState.STATE_UNLOCKED) && diff --git a/src/components/campaign/CalendarView.tsx b/src/components/campaign/CalendarView.tsx index b36d5669..5afbd1a6 100644 --- a/src/components/campaign/CalendarView.tsx +++ b/src/components/campaign/CalendarView.tsx @@ -2,13 +2,14 @@ import { FC, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; import { CalendarItemView } from './CalendarItemView'; +import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; interface CalendarViewProps { close(): void; openPackage(id: number, asStaff: boolean): void; - receivedProducts: Map; + receivedProducts: Map; campaignName: string; currentDay: number; numDays: number; @@ -128,7 +129,7 @@ export const CalendarView: FC = props => return ( - + ); }) } diff --git a/src/components/campaign/CampaignView.tsx b/src/components/campaign/CampaignView.tsx index 1a7cf339..3464f29f 100644 --- a/src/components/campaign/CampaignView.tsx +++ b/src/components/campaign/CampaignView.tsx @@ -3,12 +3,13 @@ import { FC, useCallback, useEffect, useState } from 'react'; import { AddEventLinkTracker, RemoveLinkEventTracker, SendMessageComposer } from '../../api'; import { BatchUpdates, UseMessageEventHook } from '../../hooks'; import { CalendarView } from './CalendarView'; +import { CalendarItem } from './common/CalendarItem'; export const CampaignView: FC<{}> = props => { const [ calendarData, setCalendarData ] = useState(null); const [ lastOpenAttempt, setLastOpenAttempt ] = useState(-1); - const [ receivedProducts, setReceivedProducts ] = useState>(new Map()); + const [ receivedProducts, setReceivedProducts ] = useState>(new Map()); const [ isCalendarOpen, setCalendarOpen ] = useState(false); const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) => @@ -44,7 +45,7 @@ export const CampaignView: FC<{}> = props => setReceivedProducts(prev => { const copy = new Map(prev); - copy.set(lastAttempt, parser.furnitureClassName); + copy.set(lastAttempt, new CalendarItem(parser.productName, parser.customImage,parser.furnitureClassName)); return copy; }); diff --git a/src/components/campaign/common/CalendarItem.ts b/src/components/campaign/common/CalendarItem.ts new file mode 100644 index 00000000..d3634b3d --- /dev/null +++ b/src/components/campaign/common/CalendarItem.ts @@ -0,0 +1,30 @@ +import { ICalendarItem } from './ICalendarItem'; + +export class CalendarItem implements ICalendarItem +{ + private _productName: string; + private _customImage: string; + private _furnitureClassName: string; + + constructor(productName: string, customImage: string, furnitureClassName: string) + { + this._productName = productName; + this._customImage = customImage; + this._furnitureClassName = furnitureClassName; + } + + public get productName(): string + { + return this._productName; + } + + public get customImage(): string + { + return this._customImage; + } + + public get furnitureClassName(): string + { + return this._furnitureClassName; + } +} diff --git a/src/components/campaign/common/ICalendarItem.ts b/src/components/campaign/common/ICalendarItem.ts new file mode 100644 index 00000000..87dfbd6d --- /dev/null +++ b/src/components/campaign/common/ICalendarItem.ts @@ -0,0 +1,6 @@ +export interface ICalendarItem +{ + readonly productName: string; + readonly customImage: string; + readonly furnitureClassName: string; +} From 2a989bf6ce518c2cc4c230233ea262f876a5d6d2 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 16 Mar 2022 02:29:18 -0400 Subject: [PATCH 2/4] Fix catalog opening when reset --- src/components/catalog/CatalogView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index 115d2892..1cfbe184 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -55,7 +55,6 @@ export const CatalogView: FC<{}> = props => setActiveNodes([]); setSearchResult(null); setFrontPageItems([]); - setIsVisible(true); }); }, []); From b9b5bafaf3b74b53b628c8318ba9cc83f140aa13 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 16 Mar 2022 02:58:36 -0400 Subject: [PATCH 3/4] Add RoomEnterError listener --- src/api/nitro/session/VisitDesktop.ts | 9 ++++++ src/api/nitro/session/index.ts | 1 + .../navigator/NavigatorMessageHandler.tsx | 32 +++++++++++++++++-- src/components/toolbar/ToolbarView.tsx | 12 ++----- 4 files changed, 42 insertions(+), 12 deletions(-) create mode 100644 src/api/nitro/session/VisitDesktop.ts diff --git a/src/api/nitro/session/VisitDesktop.ts b/src/api/nitro/session/VisitDesktop.ts new file mode 100644 index 00000000..e7416a35 --- /dev/null +++ b/src/api/nitro/session/VisitDesktop.ts @@ -0,0 +1,9 @@ +import { GetRoomSession, GetRoomSessionManager, GoToDesktop } from '.'; + +export const VisitDesktop = () => +{ + if(!GetRoomSession()) return; + + GoToDesktop(); + GetRoomSessionManager().removeSession(-1); +} diff --git a/src/api/nitro/session/index.ts b/src/api/nitro/session/index.ts index 5b222369..a860d7a0 100644 --- a/src/api/nitro/session/index.ts +++ b/src/api/nitro/session/index.ts @@ -18,3 +18,4 @@ export * from './IsOwnerOfFloorFurniture'; export * from './IsOwnerOfFurniture'; export * from './IsRidingHorse'; export * from './StartRoomSession'; +export * from './VisitDesktop'; diff --git a/src/components/navigator/NavigatorMessageHandler.tsx b/src/components/navigator/NavigatorMessageHandler.tsx index 38c5f9d5..93c01d29 100644 --- a/src/components/navigator/NavigatorMessageHandler.tsx +++ b/src/components/navigator/NavigatorMessageHandler.tsx @@ -1,6 +1,6 @@ -import { GenericErrorEvent, GetGuestRoomResultEvent, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer'; +import { CantConnectMessageParser, GenericErrorEvent, GetGuestRoomResultEvent, LegacyExternalInterface, NavigatorCategoriesComposer, NavigatorCategoriesEvent, NavigatorHomeRoomEvent, NavigatorMetadataEvent, NavigatorSearchEvent, NavigatorSettingsComposer, RoomCreatedEvent, RoomDataParser, RoomDoorbellAcceptedEvent, RoomDoorbellEvent, RoomDoorbellRejectedEvent, RoomEnterErrorEvent, RoomEntryInfoMessageEvent, RoomForwardEvent, RoomInfoComposer, RoomSettingsUpdatedEvent, UserInfoEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback } from 'react'; -import { CreateRoomSession, GetSessionDataManager, SendMessageComposer } from '../../api'; +import { CreateRoomSession, GetSessionDataManager, LocalizeText, NotificationAlertType, NotificationUtilities, SendMessageComposer, VisitDesktop } from '../../api'; import { UpdateDoorStateEvent } from '../../events'; import { DispatchUiEvent, UseMessageEventHook } from '../../hooks'; import { useNavigatorContext } from './NavigatorContext'; @@ -194,6 +194,33 @@ export const NavigatorMessageHandler: FC<{}> = props => SendMessageComposer(new RoomInfoComposer(parser.roomId, false, false)); }, []); + const onRoomEnterErrorEvent = useCallback((event: RoomEnterErrorEvent) => + { + const parser = event.getParser(); + + switch(parser.reason) + { + case CantConnectMessageParser.REASON_FULL: + NotificationUtilities.simpleAlert(LocalizeText('navigator.guestroomfull.text'), NotificationAlertType.DEFAULT, null, null, LocalizeText('navigator.guestroomfull.title')); + + break; + case CantConnectMessageParser.REASON_QUEUE_ERROR: + NotificationUtilities.simpleAlert(LocalizeText(`room.queue.error.${ parser.parameter }`), NotificationAlertType.DEFAULT, null, null, LocalizeText('room.queue.error.title')); + + break; + case CantConnectMessageParser.REASON_BANNED: + NotificationUtilities.simpleAlert(LocalizeText('navigator.banned.text'), NotificationAlertType.DEFAULT, null, null, LocalizeText('navigator.banned.title')); + + break; + default: + NotificationUtilities.simpleAlert(LocalizeText('room.queue.error.title'), NotificationAlertType.DEFAULT, null, null, LocalizeText('room.queue.error.title')); + + break; + } + + VisitDesktop(); + }, []); + UseMessageEventHook(UserInfoEvent, onUserInfoEvent); UseMessageEventHook(RoomForwardEvent, onRoomForwardEvent); UseMessageEventHook(RoomEntryInfoMessageEvent, onRoomEntryInfoMessageEvent); @@ -208,6 +235,7 @@ export const NavigatorMessageHandler: FC<{}> = props => UseMessageEventHook(RoomCreatedEvent, onRoomCreatedEvent); UseMessageEventHook(NavigatorHomeRoomEvent, onNavigatorHomeRoomEvent); UseMessageEventHook(RoomSettingsUpdatedEvent, onRoomSettingsUpdatedEvent); + UseMessageEventHook(RoomEnterErrorEvent, onRoomEnterErrorEvent); return null; } diff --git a/src/components/toolbar/ToolbarView.tsx b/src/components/toolbar/ToolbarView.tsx index 06a69731..70decda4 100644 --- a/src/components/toolbar/ToolbarView.tsx +++ b/src/components/toolbar/ToolbarView.tsx @@ -1,6 +1,6 @@ import { Dispose, DropBounce, EaseOut, FigureUpdateEvent, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, UserInfoDataParser, UserInfoEvent, Wait } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api'; +import { CreateLinkEvent, GetSessionDataManager, GetUserProfile, OpenMessengerChat, VisitDesktop } from '../../api'; import { Base, Flex, LayoutAvatarImageView, LayoutItemCountView, TransitionAnimation, TransitionAnimationTypes } from '../../common'; import { AchievementsUIEvent, AchievementsUIUnseenCountEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, ModToolsEvent, NavigatorEvent, UnseenItemTrackerUpdateEvent, UserSettingsUIEvent } from '../../events'; import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; @@ -178,14 +178,6 @@ export const ToolbarView: FC = props => } }, []); - const visitDesktop = useCallback(() => - { - if(!GetRoomSession()) return; - - GoToDesktop(); - GetRoomSessionManager().removeSession(-1); - }, []); - return ( <> @@ -200,7 +192,7 @@ export const ToolbarView: FC = props => } { isInRoom && - } + VisitDesktop() } /> } { !isInRoom && CreateLinkEvent('navigator/goto/home') } /> } handleToolbarItemClick(ToolbarViewItems.NAVIGATOR_ITEM) } /> From 079a57c012d544721d4d4e73c2b01f0e94e6bc63 Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 16 Mar 2022 03:22:01 -0400 Subject: [PATCH 4/4] Calendar change --- src/components/campaign/CalendarItemView.tsx | 4 +-- src/components/campaign/CalendarView.tsx | 26 ++------------------ 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/components/campaign/CalendarItemView.tsx b/src/components/campaign/CalendarItemView.tsx index 7ca4cb66..ae81dd34 100644 --- a/src/components/campaign/CalendarItemView.tsx +++ b/src/components/campaign/CalendarItemView.tsx @@ -1,15 +1,15 @@ import { FC } from 'react'; import { GetConfiguration, GetRoomEngine, GetSessionDataManager } from '../../api'; import { Base, Column, Flex, LayoutImage } from '../../common'; -import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; +import { ICalendarItem } from './common/ICalendarItem'; interface CalendarItemViewProps { itemId: number; state: number; active?: boolean; - product?: CalendarItem; + product?: ICalendarItem; onClick: (itemId: number) => void; } diff --git a/src/components/campaign/CalendarView.tsx b/src/components/campaign/CalendarView.tsx index 5afbd1a6..40675056 100644 --- a/src/components/campaign/CalendarView.tsx +++ b/src/components/campaign/CalendarView.tsx @@ -2,14 +2,14 @@ import { FC, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../api'; import { Base, Button, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; import { CalendarItemView } from './CalendarItemView'; -import { CalendarItem } from './common/CalendarItem'; import { CalendarItemState } from './common/CalendarItemState'; +import { ICalendarItem } from './common/ICalendarItem'; interface CalendarViewProps { close(): void; openPackage(id: number, asStaff: boolean): void; - receivedProducts: Map; + receivedProducts: Map; campaignName: string; currentDay: number; numDays: number; @@ -139,28 +139,6 @@ export const CalendarView: FC = props => - {/* - - - - - - { [...Array(TOTAL_SHOWN_ITEMS)].map((e, i) => - { - const day = (index + i); - - return ( - - - - ); - }) } - - - - - - */} )