This commit is contained in:
Layne 2022-03-17 13:49:14 -04:00
commit f86b8ea287
7 changed files with 34 additions and 12 deletions

View File

@ -131,8 +131,11 @@ export const CatalogPurchaseWidgetView: FC<CatalogPurchaseWidgetViewProps> = pro
{
if(!currentOffer) return;
return () =>
{
setPurchaseState(CatalogPurchaseState.NONE);
setPurchaseOptions({ quantity: 1, extraData: '', extraParamRequired: false, previewStuffData: null });
}
}, [ currentOffer, setPurchaseOptions ]);
useEffect(() =>

View File

@ -235,8 +235,6 @@ export const NavigatorView: FC<{}> = props =>
{
if(!isVisible || !LAST_SEARCH || !LAST_SEARCH.length) return;
console.log(LAST_SEARCH)
CreateLinkEvent(`navigator/search/${ LAST_SEARCH }`);
}, [ isVisible ]);

View File

@ -47,6 +47,8 @@ export const NavigatorSearchView: FC<NavigatorSearchViewProps> = props =>
useEffect(() =>
{
if(!searchResult || !searchResult.data) return;
const searchResultDataParts = searchResult.data.split(':');
LAST_SEARCH = `${ topLevelContext.code }/${ searchResult.data }`;

View File

@ -71,6 +71,27 @@ export const NitropediaView: FC<{}> = props =>
return () => element.removeEventListener(MouseEventType.MOUSE_CLICK, onClick);
}, [ onClick, content ]);
useEffect(() =>
{
const handle = (event: MouseEvent) =>
{
if(!(event.target instanceof HTMLAnchorElement)) return;
const link = event.target.href;
if(!link || !link.length) return;
NotificationUtilities.openUrl(link);
}
document.addEventListener('click', handle);
return () =>
{
document.removeEventListener('click', handle);
}
}, []);
if(!content) return null;
return (

View File

@ -1,5 +1,4 @@
import { FC, MouseEvent, useEffect, useRef, useState } from 'react';
import { RoomChatFormatter } from '../../../../api';
import { ChatBubbleMessage } from './common/ChatBubbleMessage';
interface ChatWidgetMessageViewProps
@ -14,7 +13,6 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
const { chat = null, makeRoom = null, onChatClicked = null } = props;
const [ isVisible, setIsVisible ] = useState(false);
const elementRef = useRef<HTMLDivElement>();
const [formatted, setFormatted] = useState(null);
const onMouseDown = (event: MouseEvent<HTMLDivElement>) => onChatClicked(chat);
@ -50,13 +48,11 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
chat.visible = true;
}
if(!formatted) setFormatted(RoomChatFormatter(chat.text));
return () =>
{
chat.elementRef = null;
}
}, [ elementRef, chat, makeRoom,formatted ]);
}, [ elementRef, chat, makeRoom ]);
useEffect(() => setIsVisible(chat.visible), [ chat.visible ]);
@ -68,8 +64,8 @@ export const ChatWidgetMessageView: FC<ChatWidgetMessageViewProps> = props =>
{ (chat.imageUrl && (chat.imageUrl !== '')) && <div className="user-image" style={ { backgroundImage: 'url(' + chat.imageUrl + ')' } } /> }
</div>
<div className="chat-content">
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: `${ chat.username }: ` } } />
<span className="message" dangerouslySetInnerHTML={{ __html: formatted }} />
<b className="username mr-1" dangerouslySetInnerHTML={ { __html: chat.username } } />
<span className="message" dangerouslySetInnerHTML={{ __html: chat.formattedText }} />
</div>
<div className="pointer"></div>
</div>

View File

@ -1,6 +1,6 @@
import { NitroPoint, RoomDragEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useRef, useState } from 'react';
import { RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api';
import { RoomChatFormatter, RoomWidgetChatSelectAvatarMessage, RoomWidgetRoomObjectMessage, RoomWidgetUpdateChatEvent } from '../../../../api';
import { UseEventDispatcherHook, UseRoomEngineEvent } from '../../../../hooks';
import { useRoomContext } from '../../RoomContext';
import { ChatWidgetMessageView } from './ChatWidgetMessageView';
@ -63,6 +63,7 @@ export const ChatWidgetView: FC<{}> = props =>
event.userCategory,
event.roomId,
event.text,
RoomChatFormatter(event.text),
event.userName,
new NitroPoint(event.userX, event.userY),
event.chatType,

View File

@ -18,6 +18,7 @@ export class ChatBubbleMessage
public senderCategory: number = -1,
public roomId: number = -1,
public text: string = '',
public formattedText: string = '',
public username: string = '',
public location: INitroPoint = null,
public type: number = 0,