From c02f088045ed7ac05115136abd1f70e7a18c685c Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 17 Mar 2022 00:52:22 -0400 Subject: [PATCH] Fix toolbar my rooms, profile user rooms --- src/components/navigator/NavigatorView.tsx | 26 ++++++++++++++++--- .../views/search/NavigatorSearchView.tsx | 17 ++++++++++-- src/components/toolbar/ToolbarMeView.tsx | 14 +++++----- .../user-profile/UserProfileView.tsx | 4 +-- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/components/navigator/NavigatorView.tsx b/src/components/navigator/NavigatorView.tsx index 98595623..4afb0c98 100644 --- a/src/components/navigator/NavigatorView.tsx +++ b/src/components/navigator/NavigatorView.tsx @@ -4,7 +4,7 @@ import { FC, useCallback, useEffect, useMemo, useReducer, useState } from 'react import { AddEventLinkTracker, GoToDesktop, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api'; import { Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common'; import { NavigatorEvent, UpdateDoorStateEvent } from '../../events'; -import { UseMountEffect, UseRoomSessionManagerEvent, UseUiEvent } from '../../hooks'; +import { BatchUpdates, UseMountEffect, UseRoomSessionManagerEvent, UseUiEvent } from '../../hooks'; import { NavigatorContextProvider } from './NavigatorContext'; import { NavigatorMessageHandler } from './NavigatorMessageHandler'; import { initialNavigator, NavigatorActions, NavigatorReducer } from './reducers/NavigatorReducer'; @@ -154,11 +154,29 @@ export const NavigatorView: FC<{}> = props => } return; case 'create': - setIsVisible(true); - setCreatorOpen(true); + BatchUpdates(() => + { + setIsVisible(true); + setCreatorOpen(true); + }); + return; + case 'search': + if(parts.length > 2) + { + const topLevelContextCode = parts[2]; + + let searchValue = ''; + + if(parts.length > 3) searchValue = parts[3]; + + console.log(searchValue, topLevelContextCode) + + setIsVisible(true); + sendSearch(searchValue, topLevelContextCode); + } return; } - }, [ goToHomeRoom ]); + }, [ goToHomeRoom, sendSearch ]); const closePendingDoorState = useCallback((state: string) => { diff --git a/src/components/navigator/views/search/NavigatorSearchView.tsx b/src/components/navigator/views/search/NavigatorSearchView.tsx index 0ab7a2a3..ecc73e0b 100644 --- a/src/components/navigator/views/search/NavigatorSearchView.tsx +++ b/src/components/navigator/views/search/NavigatorSearchView.tsx @@ -1,5 +1,5 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import React, { FC, KeyboardEvent, useCallback, useState } from 'react'; +import React, { FC, KeyboardEvent, useCallback, useEffect, useState } from 'react'; import { LocalizeText } from '../../../../api'; import { Button } from '../../../../common/Button'; import { Flex } from '../../../../common/Flex'; @@ -18,7 +18,7 @@ export const NavigatorSearchView: FC = props => const [ searchValue, setSearchValue ] = useState(''); const [ lastSearchQuery, setLastSearchQuery ] = useState(''); const { navigatorState = null } = useNavigatorContext(); - const { topLevelContext = null } = navigatorState; + const { topLevelContext = null, searchResult = null } = navigatorState; const processSearch = useCallback(() => { @@ -43,6 +43,19 @@ export const NavigatorSearchView: FC = props => processSearch(); }; + useEffect(() => + { + const searchResultDataParts = searchResult.data.split(':'); + + if(searchResultDataParts.length === 2) + { + let searchFilterIndex = SearchFilterOptions.findIndex(option => (option.query === searchResultDataParts[0])); + + if(searchFilterIndex > -1) setSearchFilterIndex(searchFilterIndex); + setSearchValue(searchResultDataParts[1]); + } + }, [ searchResult ]); + return ( diff --git a/src/components/toolbar/ToolbarMeView.tsx b/src/components/toolbar/ToolbarMeView.tsx index 85cff7b7..6e0b7a3e 100644 --- a/src/components/toolbar/ToolbarMeView.tsx +++ b/src/components/toolbar/ToolbarMeView.tsx @@ -1,6 +1,6 @@ import { RoomObjectCategory } from '@nitrots/nitro-renderer'; import { FC, useEffect } from 'react'; -import { GetRoomEngine, GetRoomSession } from '../../api'; +import { CreateLinkEvent, GetRoomEngine, GetRoomSession } from '../../api'; import { Base, Flex, LayoutItemCountView } from '../../common'; import { ToolbarViewItems } from './common/ToolbarViewItems'; @@ -27,15 +27,15 @@ export const ToolbarMeView: FC = props => return ( { useGuideTool && - handleToolbarItemClick(ToolbarViewItems.GUIDE_TOOL_ITEM) } /> } - handleToolbarItemClick(ToolbarViewItems.ACHIEVEMENTS_ITEM) }> + handleToolbarItemClick(ToolbarViewItems.GUIDE_TOOL_ITEM) } /> } + handleToolbarItemClick(ToolbarViewItems.ACHIEVEMENTS_ITEM) }> { (unseenAchievementCount > 0) && } - handleToolbarItemClick(ToolbarViewItems.PROFILE_ITEM) } /> - - handleToolbarItemClick(ToolbarViewItems.CLOTHING_ITEM) } /> - handleToolbarItemClick(ToolbarViewItems.SETTINGS_ITEM) } /> + handleToolbarItemClick(ToolbarViewItems.PROFILE_ITEM) } /> + CreateLinkEvent('navigator/search/myworld_view')} /> + handleToolbarItemClick(ToolbarViewItems.CLOTHING_ITEM) } /> + handleToolbarItemClick(ToolbarViewItems.SETTINGS_ITEM) } /> ); } diff --git a/src/components/user-profile/UserProfileView.tsx b/src/components/user-profile/UserProfileView.tsx index 9454370a..bfc1892e 100644 --- a/src/components/user-profile/UserProfileView.tsx +++ b/src/components/user-profile/UserProfileView.tsx @@ -1,6 +1,6 @@ import { RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectType, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; -import { GetRoomSession, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api'; +import { CreateLinkEvent, GetRoomSession, GetSessionDataManager, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api'; import { Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common'; import { BatchUpdates, UseMessageEventHook, UseRoomEngineEvent } from '../../hooks'; import { BadgesContainerView } from './views/BadgesContainerView'; @@ -104,7 +104,7 @@ export const UserProfileView: FC<{}> = props => - + CreateLinkEvent(`navigator/search/hotel_view/owner:${ userProfile.username }`)}> { LocalizeText('extendedprofile.rooms') }