mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 08:50:51 +01:00
Refresh navigator on reopen
This commit is contained in:
parent
26446a1a56
commit
c58d7ccce1
@ -1,7 +1,7 @@
|
|||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { ConvertGlobalRoomIdMessageComposer, HabboWebTools, ILinkEventTracker, LegacyExternalInterface, NavigatorInitComposer, NavigatorSearchComposer, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer';
|
import { ConvertGlobalRoomIdMessageComposer, HabboWebTools, ILinkEventTracker, LegacyExternalInterface, NavigatorInitComposer, NavigatorSearchComposer, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useCallback, useEffect, useMemo, useReducer, useState } from 'react';
|
import { FC, useCallback, useEffect, useMemo, useReducer, useState } from 'react';
|
||||||
import { AddEventLinkTracker, GoToDesktop, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api';
|
import { AddEventLinkTracker, CreateLinkEvent, GoToDesktop, LocalizeText, RemoveLinkEventTracker, SendMessageComposer, TryVisitRoom } from '../../api';
|
||||||
import { Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
|
import { Column, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
|
||||||
import { NavigatorEvent, UpdateDoorStateEvent } from '../../events';
|
import { NavigatorEvent, UpdateDoorStateEvent } from '../../events';
|
||||||
import { BatchUpdates, UseMountEffect, UseRoomSessionManagerEvent, UseUiEvent } from '../../hooks';
|
import { BatchUpdates, UseMountEffect, UseRoomSessionManagerEvent, UseUiEvent } from '../../hooks';
|
||||||
@ -15,7 +15,7 @@ import { NavigatorRoomLinkView } from './views/room-link/NavigatorRoomLinkView';
|
|||||||
import { NavigatorRoomPasswordView } from './views/room-password/NavigatorRoomPasswordView';
|
import { NavigatorRoomPasswordView } from './views/room-password/NavigatorRoomPasswordView';
|
||||||
import { NavigatorRoomSettingsView } from './views/room-settings/NavigatorRoomSettingsView';
|
import { NavigatorRoomSettingsView } from './views/room-settings/NavigatorRoomSettingsView';
|
||||||
import { NavigatorSearchResultView } from './views/search-result/NavigatorSearchResultView';
|
import { NavigatorSearchResultView } from './views/search-result/NavigatorSearchResultView';
|
||||||
import { NavigatorSearchView } from './views/search/NavigatorSearchView';
|
import { LAST_SEARCH, NavigatorSearchView } from './views/search/NavigatorSearchView';
|
||||||
|
|
||||||
export const NavigatorView: FC<{}> = props =>
|
export const NavigatorView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
@ -169,8 +169,6 @@ export const NavigatorView: FC<{}> = props =>
|
|||||||
|
|
||||||
if(parts.length > 3) searchValue = parts[3];
|
if(parts.length > 3) searchValue = parts[3];
|
||||||
|
|
||||||
console.log(searchValue, topLevelContextCode)
|
|
||||||
|
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
sendSearch(searchValue, topLevelContextCode);
|
sendSearch(searchValue, topLevelContextCode);
|
||||||
}
|
}
|
||||||
@ -233,6 +231,15 @@ export const NavigatorView: FC<{}> = props =>
|
|||||||
sendSearch('', topLevelContexts[0].code);
|
sendSearch('', topLevelContexts[0].code);
|
||||||
}, [ topLevelContexts, sendSearch ]);
|
}, [ topLevelContexts, sendSearch ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
if(!isVisible || !LAST_SEARCH || !LAST_SEARCH.length) return;
|
||||||
|
|
||||||
|
console.log(LAST_SEARCH)
|
||||||
|
|
||||||
|
CreateLinkEvent(`navigator/search/${ LAST_SEARCH }`);
|
||||||
|
}, [ isVisible ]);
|
||||||
|
|
||||||
const getRoomDoorState = useMemo(() =>
|
const getRoomDoorState = useMemo(() =>
|
||||||
{
|
{
|
||||||
if(!pendingDoorState) return null;
|
if(!pendingDoorState) return null;
|
||||||
|
@ -231,7 +231,7 @@ export const NavigatorRoomSettingsView: FC<{}> = props =>
|
|||||||
</NitroCardTabsView>
|
</NitroCardTabsView>
|
||||||
<NitroCardContentView>
|
<NitroCardContentView>
|
||||||
{ currentTab === TABS[0] &&
|
{ currentTab === TABS[0] &&
|
||||||
<NavigatorRoomSettingsBasicTabView roomSettingsData={ roomSettingsData } handleChange={ handleChange } /> }
|
<NavigatorRoomSettingsBasicTabView roomSettingsData={ roomSettingsData } handleChange={ handleChange } close={ () => processAction('close') } /> }
|
||||||
{ currentTab === TABS[1] &&
|
{ currentTab === TABS[1] &&
|
||||||
<NavigatorRoomSettingsAccessTabView roomSettingsData={ roomSettingsData } handleChange={ handleChange } /> }
|
<NavigatorRoomSettingsAccessTabView roomSettingsData={ roomSettingsData } handleChange={ handleChange } /> }
|
||||||
{ currentTab === TABS[2] &&
|
{ currentTab === TABS[2] &&
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import { FC, useCallback } from 'react';
|
import { FC, useCallback } from 'react';
|
||||||
import { LocalizeText } from '../../../../../api';
|
import { LocalizeText } from '../../../../../api';
|
||||||
import { Column, Flex, Text } from '../../../../../common';
|
import { Column, Flex, Text } from '../../../../../common';
|
||||||
import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types';
|
import RoomSettingsData from '../../../common/RoomSettingsData';
|
||||||
|
|
||||||
|
interface NavigatorRoomSettingsTabViewProps
|
||||||
|
{
|
||||||
|
roomSettingsData: RoomSettingsData;
|
||||||
|
handleChange: (field: string, value: string | number | boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export const NavigatorRoomSettingsAccessTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
export const NavigatorRoomSettingsAccessTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
||||||
{
|
{
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { RoomDeleteComposer } from '@nitrots/nitro-renderer';
|
import { RoomDeleteComposer } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from 'react';
|
||||||
import { LocalizeText, NotificationUtilities, SendMessageComposer } from '../../../../../api';
|
import { CreateLinkEvent, LocalizeText, NotificationUtilities, SendMessageComposer } from '../../../../../api';
|
||||||
import { Base, Flex, Text } from '../../../../../common';
|
import { Base, Flex, Text } from '../../../../../common';
|
||||||
|
import RoomSettingsData from '../../../common/RoomSettingsData';
|
||||||
import { GetMaxVisitorsList } from '../../../common/RoomSettingsUtils';
|
import { GetMaxVisitorsList } from '../../../common/RoomSettingsUtils';
|
||||||
import { useNavigatorContext } from '../../../NavigatorContext';
|
import { useNavigatorContext } from '../../../NavigatorContext';
|
||||||
import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types';
|
|
||||||
|
|
||||||
const DESC_MAX_LENGTH = 255;
|
const DESC_MAX_LENGTH = 255;
|
||||||
|
|
||||||
|
interface NavigatorRoomSettingsTabViewProps
|
||||||
|
{
|
||||||
|
roomSettingsData: RoomSettingsData;
|
||||||
|
handleChange: (field: string, value: string | number | boolean) => void;
|
||||||
|
close: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export const NavigatorRoomSettingsBasicTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
export const NavigatorRoomSettingsBasicTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { roomSettingsData = null, handleChange = null } = props;
|
const { roomSettingsData = null, handleChange = null, close = null } = props;
|
||||||
const [ maxVisitorsList, setMaxVisitorsList ] = useState(GetMaxVisitorsList());
|
const [ maxVisitorsList, setMaxVisitorsList ] = useState(GetMaxVisitorsList());
|
||||||
const { navigatorState = null } = useNavigatorContext();
|
const { navigatorState = null } = useNavigatorContext();
|
||||||
const { categories = null } = navigatorState;
|
const { categories = null } = navigatorState;
|
||||||
@ -21,6 +29,10 @@ export const NavigatorRoomSettingsBasicTabView: FC<NavigatorRoomSettingsTabViewP
|
|||||||
NotificationUtilities.confirm(LocalizeText('navigator.roomsettings.deleteroom.confirm.message'), () =>
|
NotificationUtilities.confirm(LocalizeText('navigator.roomsettings.deleteroom.confirm.message'), () =>
|
||||||
{
|
{
|
||||||
SendMessageComposer(new RoomDeleteComposer(roomSettingsData.roomId));
|
SendMessageComposer(new RoomDeleteComposer(roomSettingsData.roomId));
|
||||||
|
|
||||||
|
if(close) close();
|
||||||
|
|
||||||
|
CreateLinkEvent('navigator/search/myworld_view');
|
||||||
},
|
},
|
||||||
null, null, null, LocalizeText('navigator.roomsettings.deleteroom.confirm.title'));
|
null, null, null, LocalizeText('navigator.roomsettings.deleteroom.confirm.title'));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,13 @@ import { RoomUnbanUserComposer } from '@nitrots/nitro-renderer';
|
|||||||
import { FC, useCallback, useState } from 'react';
|
import { FC, useCallback, useState } from 'react';
|
||||||
import { LocalizeText, SendMessageComposer } from '../../../../../api';
|
import { LocalizeText, SendMessageComposer } from '../../../../../api';
|
||||||
import { Base, Button, Column, Grid, Text } from '../../../../../common';
|
import { Base, Button, Column, Grid, Text } from '../../../../../common';
|
||||||
import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types';
|
import RoomSettingsData from '../../../common/RoomSettingsData';
|
||||||
|
|
||||||
|
interface NavigatorRoomSettingsTabViewProps
|
||||||
|
{
|
||||||
|
roomSettingsData: RoomSettingsData;
|
||||||
|
handleChange: (field: string, value: string | number | boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export const NavigatorRoomSettingsModTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
export const NavigatorRoomSettingsModTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,13 @@ import { RemoveAllRightsMessageComposer, RoomTakeRightsComposer } from '@nitrots
|
|||||||
import { FC, useCallback } from 'react';
|
import { FC, useCallback } from 'react';
|
||||||
import { LocalizeText, SendMessageComposer } from '../../../../../api';
|
import { LocalizeText, SendMessageComposer } from '../../../../../api';
|
||||||
import { Button, Column, Flex, Grid, Text, UserProfileIconView } from '../../../../../common';
|
import { Button, Column, Flex, Grid, Text, UserProfileIconView } from '../../../../../common';
|
||||||
import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types';
|
import RoomSettingsData from '../../../common/RoomSettingsData';
|
||||||
|
|
||||||
|
interface NavigatorRoomSettingsTabViewProps
|
||||||
|
{
|
||||||
|
roomSettingsData: RoomSettingsData;
|
||||||
|
handleChange: (field: string, value: string | number | boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
export const NavigatorRoomSettingsRightsTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
||||||
{
|
{
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
import RoomSettingsData from '../../../common/RoomSettingsData';
|
|
||||||
|
|
||||||
export class NavigatorRoomSettingsTabViewProps
|
|
||||||
{
|
|
||||||
roomSettingsData: RoomSettingsData;
|
|
||||||
handleChange: (field: string, value: string | number | boolean) => void;
|
|
||||||
}
|
|
@ -1,10 +1,13 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { LocalizeText } from '../../../../../api';
|
import { LocalizeText } from '../../../../../api';
|
||||||
import { Column } from '../../../../../common/Column';
|
import { Column, Flex, Grid, Text } from '../../../../../common';
|
||||||
import { Flex } from '../../../../../common/Flex';
|
import RoomSettingsData from '../../../common/RoomSettingsData';
|
||||||
import { Grid } from '../../../../../common/Grid';
|
|
||||||
import { Text } from '../../../../../common/Text';
|
interface NavigatorRoomSettingsTabViewProps
|
||||||
import { NavigatorRoomSettingsTabViewProps } from './NavigatorRoomSettingsTabViewProps.types';
|
{
|
||||||
|
roomSettingsData: RoomSettingsData;
|
||||||
|
handleChange: (field: string, value: string | number | boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export const NavigatorRoomSettingsVipChatTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
export const NavigatorRoomSettingsVipChatTabView: FC<NavigatorRoomSettingsTabViewProps> = props =>
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,8 @@ export interface NavigatorSearchViewProps
|
|||||||
sendSearch: (searchValue: string, contextCode: string) => void;
|
sendSearch: (searchValue: string, contextCode: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export let LAST_SEARCH: string = null;
|
||||||
|
|
||||||
export const NavigatorSearchView: FC<NavigatorSearchViewProps> = props =>
|
export const NavigatorSearchView: FC<NavigatorSearchViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { sendSearch = null } = props;
|
const { sendSearch = null } = props;
|
||||||
@ -47,6 +49,8 @@ export const NavigatorSearchView: FC<NavigatorSearchViewProps> = props =>
|
|||||||
{
|
{
|
||||||
const searchResultDataParts = searchResult.data.split(':');
|
const searchResultDataParts = searchResult.data.split(':');
|
||||||
|
|
||||||
|
LAST_SEARCH = `${ topLevelContext.code }/${ searchResult.data }`;
|
||||||
|
|
||||||
if(searchResultDataParts.length === 2)
|
if(searchResultDataParts.length === 2)
|
||||||
{
|
{
|
||||||
let searchFilterIndex = SearchFilterOptions.findIndex(option => (option.query === searchResultDataParts[0]));
|
let searchFilterIndex = SearchFilterOptions.findIndex(option => (option.query === searchResultDataParts[0]));
|
||||||
@ -54,7 +58,7 @@ export const NavigatorSearchView: FC<NavigatorSearchViewProps> = props =>
|
|||||||
if(searchFilterIndex > -1) setSearchFilterIndex(searchFilterIndex);
|
if(searchFilterIndex > -1) setSearchFilterIndex(searchFilterIndex);
|
||||||
setSearchValue(searchResultDataParts[1]);
|
setSearchValue(searchResultDataParts[1]);
|
||||||
}
|
}
|
||||||
}, [ searchResult ]);
|
}, [ searchResult, topLevelContext ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex fullWidth gap={ 1 }>
|
<Flex fullWidth gap={ 1 }>
|
||||||
|
Loading…
Reference in New Issue
Block a user