mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
Random changes
This commit is contained in:
parent
567d3fdb66
commit
51960f7e50
14
src/api/utils/CloneObject.ts
Normal file
14
src/api/utils/CloneObject.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export const CloneObject = <T>(object: T): T =>
|
||||||
|
{
|
||||||
|
if((object == null) || ('object' != typeof object)) return object;
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
const copy = new object.constructor();
|
||||||
|
|
||||||
|
for(const attr in object)
|
||||||
|
{
|
||||||
|
if(object.hasOwnProperty(attr)) copy[attr] = object[attr];
|
||||||
|
}
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
export * from './CloneObject';
|
||||||
export * from './ColorUtils';
|
export * from './ColorUtils';
|
||||||
export * from './LocalizeBadgeDescription';
|
export * from './LocalizeBadgeDescription';
|
||||||
export * from './LocalizeBageName';
|
export * from './LocalizeBageName';
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { CSSProperties, DetailedHTMLProps, FC, HTMLAttributes, LegacyRef, useMemo } from 'react';
|
import { CSSProperties, DetailedHTMLProps, FC, HTMLAttributes, MutableRefObject, useMemo } from 'react';
|
||||||
import { ColorVariantType, DisplayType, FloatType, OverflowType, PositionType } from './types';
|
import { ColorVariantType, DisplayType, FloatType, OverflowType, PositionType } from './types';
|
||||||
|
|
||||||
export interface BaseProps<T = HTMLElement> extends DetailedHTMLProps<HTMLAttributes<T>, T>
|
export interface BaseProps<T = HTMLElement> extends DetailedHTMLProps<HTMLAttributes<T>, T>
|
||||||
{
|
{
|
||||||
innerRef?: LegacyRef<T>;
|
innerRef?: MutableRefObject<T>;
|
||||||
display?: DisplayType;
|
display?: DisplayType;
|
||||||
fit?: boolean;
|
fit?: boolean;
|
||||||
grow?: boolean;
|
grow?: boolean;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { NitroLogger } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { AddEventLinkTracker, GetConfiguration, NotificationUtilities, RemoveLinkEventTracker } from '../../api';
|
import { AddEventLinkTracker, GetConfiguration, NotificationUtilities, RemoveLinkEventTracker } from '../../api';
|
||||||
import { Base, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common';
|
import { Base, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common';
|
||||||
@ -13,19 +14,28 @@ export const NitropediaView: FC<{}> = props =>
|
|||||||
|
|
||||||
const openPage = useCallback(async (link: string) =>
|
const openPage = useCallback(async (link: string) =>
|
||||||
{
|
{
|
||||||
const response = await fetch(link);
|
console.log(link);
|
||||||
|
try
|
||||||
if(!response) return;
|
|
||||||
|
|
||||||
const text = await response.text();
|
|
||||||
|
|
||||||
const splitData = text.split(NEW_LINE_REGEX);
|
|
||||||
|
|
||||||
BatchUpdates(() =>
|
|
||||||
{
|
{
|
||||||
setHeader(splitData.shift());
|
const response = await fetch(link);
|
||||||
setContent(splitData.join(''));
|
|
||||||
});
|
if(!response) return;
|
||||||
|
|
||||||
|
const text = await response.text();
|
||||||
|
|
||||||
|
const splitData = text.split(NEW_LINE_REGEX);
|
||||||
|
|
||||||
|
BatchUpdates(() =>
|
||||||
|
{
|
||||||
|
setHeader(splitData.shift());
|
||||||
|
setContent(splitData.join(''));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (error)
|
||||||
|
{
|
||||||
|
NitroLogger.error(`Failed to fetch ${ link }`);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const onLinkReceived = useCallback((link: string) =>
|
const onLinkReceived = useCallback((link: string) =>
|
||||||
|
@ -121,7 +121,7 @@ export const RoomView: FC<RoomViewProps> = props =>
|
|||||||
GetNitroInstance().render();
|
GetNitroInstance().render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(elementRef && elementRef.current) elementRef.current.appendChild(canvas);
|
if(elementRef && elementRef.current) elementRef.current.replaceChildren(canvas);
|
||||||
|
|
||||||
setCanvasId(canvasId);
|
setCanvasId(canvasId);
|
||||||
}, [ roomSession ]);
|
}, [ roomSession ]);
|
||||||
|
@ -199,7 +199,6 @@ export const AvatarInfoWidgetAvatarView: FC<AvatarInfoWidgetAvatarViewProps> = p
|
|||||||
break;
|
break;
|
||||||
case 'rship_none':
|
case 'rship_none':
|
||||||
messageType = RoomWidgetUserActionMessage.RELATIONSHIP_NONE;
|
messageType = RoomWidgetUserActionMessage.RELATIONSHIP_NONE;
|
||||||
console.log('here')
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,11 +23,7 @@ export const FurnitureBackgroundColorView: FC<{}> = props =>
|
|||||||
|
|
||||||
const canOpenBackgroundToner = useCallback(() =>
|
const canOpenBackgroundToner = useCallback(() =>
|
||||||
{
|
{
|
||||||
const isRoomOwner = roomSession.isRoomOwner;
|
return (roomSession.isRoomOwner || (roomSession.controllerLevel >= RoomControllerLevel.GUEST) || GetSessionDataManager().isModerator);
|
||||||
const hasLevel = (roomSession.controllerLevel >= RoomControllerLevel.GUEST);
|
|
||||||
const isGodMode = GetSessionDataManager().isGodMode;
|
|
||||||
|
|
||||||
return (isRoomOwner || hasLevel || isGodMode);
|
|
||||||
}, [ roomSession ]);
|
}, [ roomSession ]);
|
||||||
|
|
||||||
const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) =>
|
const onRoomEngineObjectEvent = useCallback((event: RoomEngineObjectEvent) =>
|
||||||
|
@ -30,7 +30,7 @@ export const InfoStandWidgetUserRelationshipsView: FC<InfoStandWidgetUserRelatio
|
|||||||
<i className={`nitro-friends-spritesheet icon-${relationshipName}`} />
|
<i className={`nitro-friends-spritesheet icon-${relationshipName}`} />
|
||||||
<Flex alignItems="center" gap={ 0 }>
|
<Flex alignItems="center" gap={ 0 }>
|
||||||
<Text small variant="white" onClick={ event => GetUserProfile(relationshipInfo.randomFriendId) }>
|
<Text small variant="white" onClick={ event => GetUserProfile(relationshipInfo.randomFriendId) }>
|
||||||
{ relationshipInfo.randomFriendName }
|
<u>{ relationshipInfo.randomFriendName }</u>
|
||||||
{ (relationshipInfo.friendCount > 1) && (' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationshipInfo.friendCount - 1).toString() ])) }
|
{ (relationshipInfo.friendCount > 1) && (' ' + LocalizeText(`extendedprofile.relstatus.others.${ relationshipName }`, [ 'count' ], [ (relationshipInfo.friendCount - 1).toString() ])) }
|
||||||
</Text>
|
</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -66,11 +66,6 @@ export const RoomToolsWidgetView: FC<{}> = props =>
|
|||||||
return () => clearTimeout(timeout);
|
return () => clearTimeout(timeout);
|
||||||
}, [ roomName, roomOwner, roomTags ]);
|
}, [ roomName, roomOwner, roomTags ]);
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
console.log(navigatorData);
|
|
||||||
}, [ navigatorData ]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex className="nitro-room-tools-container" gap={ 2 }>
|
<Flex className="nitro-room-tools-container" gap={ 2 }>
|
||||||
<Column center className="nitro-room-tools p-2">
|
<Column center className="nitro-room-tools p-2">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user