updated packets

This commit is contained in:
dank074 2021-10-20 19:28:50 -05:00
parent 1ba006f687
commit e0fa891266
7 changed files with 49 additions and 31 deletions

View File

@ -1,4 +1,4 @@
import { ChatRecordData, ModtoolRequestRoomChatlogComposer, ModtoolRoomChatlogEvent } from '@nitrots/nitro-renderer'; import { ChatRecordData, GetRoomChatlogMessageComposer, ModtoolRoomChatlogEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages'; import { CreateMessageHook, SendMessageHook } from '../../../../../hooks/messages';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout';
@ -13,7 +13,7 @@ export const ModToolsChatlogView: FC<ModToolsChatlogViewProps> = props =>
useEffect(() => useEffect(() =>
{ {
SendMessageHook(new ModtoolRequestRoomChatlogComposer(roomId)); SendMessageHook(new GetRoomChatlogMessageComposer(roomId));
}, [roomId]); }, [roomId]);
const onModtoolRoomChatlogEvent = useCallback((event: ModtoolRoomChatlogEvent) => const onModtoolRoomChatlogEvent = useCallback((event: ModtoolRoomChatlogEvent) =>

View File

@ -1,4 +1,4 @@
import { ModerateRoomMessageComposer, ModeratorActionMessageComposer, ModtoolRequestRoomInfoComposer, ModtoolRoomInfoEvent } from '@nitrots/nitro-renderer'; import { GetModeratorRoomInfoMessageComposer, ModerateRoomMessageComposer, ModeratorActionMessageComposer, ModeratorRoomInfoEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { TryVisitRoom } from '../../../../../api'; import { TryVisitRoom } from '../../../../../api';
import { ModToolsOpenRoomChatlogEvent } from '../../../../../events/mod-tools/ModToolsOpenRoomChatlogEvent'; import { ModToolsOpenRoomChatlogEvent } from '../../../../../events/mod-tools/ModToolsOpenRoomChatlogEvent';
@ -30,25 +30,25 @@ export const ModToolsRoomView: FC<ModToolsRoomViewProps> = props =>
{ {
if(infoRequested) return; if(infoRequested) return;
SendMessageHook(new ModtoolRequestRoomInfoComposer(roomId)); SendMessageHook(new GetModeratorRoomInfoMessageComposer(roomId));
setInfoRequested(true); setInfoRequested(true);
}, [ roomId, infoRequested, setInfoRequested ]); }, [ roomId, infoRequested, setInfoRequested ]);
const onModtoolRoomInfoEvent = useCallback((event: ModtoolRoomInfoEvent) => const onModtoolRoomInfoEvent = useCallback((event: ModeratorRoomInfoEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
if(!parser || parser.id !== roomId) return; if(!parser || parser.data.flatId !== roomId) return;
setLoadedRoomId(parser.id); setLoadedRoomId(parser.data.flatId);
setName(parser.name); setName(parser.data.room.name);
setOwnerId(parser.ownerId); setOwnerId(parser.data.ownerId);
setOwnerName(parser.ownerName); setOwnerName(parser.data.ownerName);
setOwnerInRoom(parser.ownerInRoom); setOwnerInRoom(parser.data.ownerInRoom);
setUsersInRoom(parser.playerAmount); setUsersInRoom(parser.data.userCount);
}, [ setLoadedRoomId, setName, setOwnerId, setOwnerName, setOwnerInRoom, setUsersInRoom, roomId ]); }, [ setLoadedRoomId, setName, setOwnerId, setOwnerName, setOwnerInRoom, setUsersInRoom, roomId ]);
CreateMessageHook(ModtoolRoomInfoEvent, onModtoolRoomInfoEvent); CreateMessageHook(ModeratorRoomInfoEvent, onModtoolRoomInfoEvent);
const handleClick = useCallback((action: string, value?: string) => const handleClick = useCallback((action: string, value?: string) =>
{ {

View File

@ -0,0 +1,6 @@
import { FC } from 'react';
export const ModToolsOpenIssuesTabView: FC<{}> = props =>
{
return null;
}

View File

@ -1,5 +1,6 @@
import { FC, useState } from 'react'; import { FC, useCallback, useState } from 'react';
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../layout'; import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../../../layout';
import { ModToolsOpenIssuesTabView } from './ModToolsOpenIssuesTabView';
import { ModToolsTicketsViewProps } from './ModToolsTicketsView.types'; import { ModToolsTicketsViewProps } from './ModToolsTicketsView.types';
const TABS: string[] = [ const TABS: string[] = [
@ -14,6 +15,15 @@ export const ModToolsTicketsView: FC<ModToolsTicketsViewProps> = props =>
const [ currentTab, setCurrentTab ] = useState<number>(0); const [ currentTab, setCurrentTab ] = useState<number>(0);
const CurrentTabComponent = useCallback(() =>
{
switch(currentTab)
{
case 0: return <ModToolsOpenIssuesTabView />;
default: return null;
}
}, [currentTab]);
return ( return (
<NitroCardView className="nitro-mod-tools-tickets" simple={ false }> <NitroCardView className="nitro-mod-tools-tickets" simple={ false }>
<NitroCardHeaderView headerText={ 'Tickets' } onCloseClick={ onCloseClick } /> <NitroCardHeaderView headerText={ 'Tickets' } onCloseClick={ onCloseClick } />
@ -26,7 +36,9 @@ export const ModToolsTicketsView: FC<ModToolsTicketsViewProps> = props =>
</NitroCardTabsItemView>); </NitroCardTabsItemView>);
}) } }) }
</NitroCardTabsView> </NitroCardTabsView>
<div className="p-2"></div> <div className="p-2">
<CurrentTabComponent />
</div>
</NitroCardContentView> </NitroCardContentView>
</NitroCardView> </NitroCardView>
); );

View File

@ -1,4 +1,4 @@
import { ChatRecordData, ModtoolRequestUserChatlogComposer, ModtoolUserChatlogEvent } from '@nitrots/nitro-renderer'; import { ChatRecordData, GetUserChatlogMessageComposer, UserChatlogEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { CreateMessageHook, SendMessageHook } from '../../../../../hooks'; import { CreateMessageHook, SendMessageHook } from '../../../../../hooks';
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout'; import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../layout';
@ -13,20 +13,20 @@ export const ModToolsUserChatlogView: FC<ModToolsUserChatlogViewProps> = props =
useEffect(() => useEffect(() =>
{ {
SendMessageHook(new ModtoolRequestUserChatlogComposer(userId)); SendMessageHook(new GetUserChatlogMessageComposer(userId));
}, [userId]); }, [userId]);
const onModtoolUserChatlogEvent = useCallback((event: ModtoolUserChatlogEvent) => const onModtoolUserChatlogEvent = useCallback((event: UserChatlogEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
if(!parser || parser.userId !== userId) return; if(!parser || parser.data.userId !== userId) return;
setUsername(parser.username); setUsername(parser.data.username);
setUserChatlog(parser.roomVisits); setUserChatlog(parser.data.roomChatlogs);
}, [setUsername, setUserChatlog, userId]); }, [setUsername, setUserChatlog, userId]);
CreateMessageHook(ModtoolUserChatlogEvent, onModtoolUserChatlogEvent); CreateMessageHook(UserChatlogEvent, onModtoolUserChatlogEvent);
return ( return (
<NitroCardView className="nitro-mod-tools-user-chatlog" simple={true}> <NitroCardView className="nitro-mod-tools-user-chatlog" simple={true}>

View File

@ -1,4 +1,4 @@
import { FriendlyTime, ModeratorUserInfoData, ModtoolRequestUserInfoComposer, ModtoolUserInfoEvent } from '@nitrots/nitro-renderer'; import { FriendlyTime, GetModeratorUserInfoMessageComposer, ModeratorUserInfoData, ModtoolUserInfoEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { FC, useCallback, useEffect, useMemo, useState } from 'react';
import { LocalizeText } from '../../../../../api'; import { LocalizeText } from '../../../../../api';
import { ModToolsOpenUserChatlogEvent } from '../../../../../events/mod-tools/ModToolsOpenUserChatlogEvent'; import { ModToolsOpenUserChatlogEvent } from '../../../../../events/mod-tools/ModToolsOpenUserChatlogEvent';
@ -19,7 +19,7 @@ export const ModToolsUserView: FC<ModToolsUserViewProps> = props =>
useEffect(() => useEffect(() =>
{ {
SendMessageHook(new ModtoolRequestUserInfoComposer(userId)); SendMessageHook(new GetModeratorUserInfoMessageComposer(userId));
}, [ userId ]); }, [ userId ]);
const onModtoolUserInfoEvent = useCallback((event: ModtoolUserInfoEvent) => const onModtoolUserInfoEvent = useCallback((event: ModtoolUserInfoEvent) =>
@ -109,11 +109,11 @@ export const ModToolsUserView: FC<ModToolsUserViewProps> = props =>
<NitroLayoutGridColumn size={ 8 }> <NitroLayoutGridColumn size={ 8 }>
<table className="table table-striped table-sm table-text-small text-black m-0"> <table className="table table-striped table-sm table-text-small text-black m-0">
<tbody> <tbody>
{ userProperties.map(property => { userProperties.map( (property, index) =>
{ {
return ( return (
<tr> <tr key={index}>
<th scope="row">{ LocalizeText(property.localeKey) }</th> <th scope="row">{ LocalizeText(property.localeKey) }</th>
<td> <td>
{ property.value } { property.value }

View File

@ -1,4 +1,4 @@
import { ModtoolReceivedRoomsUserEvent, ModtoolRequestUserRoomsComposer, ModtoolRoomVisitedData } from '@nitrots/nitro-renderer'; import { GetRoomVisitsMessageComposer, RoomVisitsData, RoomVisitsEvent } from '@nitrots/nitro-renderer';
import { FC, useCallback, useEffect, useState } from 'react'; import { FC, useCallback, useEffect, useState } from 'react';
import { AutoSizer, List, ListRowProps, ListRowRenderer } from 'react-virtualized'; import { AutoSizer, List, ListRowProps, ListRowRenderer } from 'react-virtualized';
import { TryVisitRoom } from '../../../../../api'; import { TryVisitRoom } from '../../../../../api';
@ -10,14 +10,14 @@ export const ModToolsUserRoomVisitsView: FC<ModToolsUserRoomVisitsViewProps> = p
{ {
const { userId = null, onCloseClick = null } = props; const { userId = null, onCloseClick = null } = props;
const [roomVisitData, setRoomVisitData] = useState<ModtoolRoomVisitedData>(null); const [roomVisitData, setRoomVisitData] = useState<RoomVisitsData>(null);
useEffect(() => useEffect(() =>
{ {
SendMessageHook(new ModtoolRequestUserRoomsComposer(userId)); SendMessageHook(new GetRoomVisitsMessageComposer(userId));
}, [userId]); }, [userId]);
const onModtoolReceivedRoomsUserEvent = useCallback((event: ModtoolReceivedRoomsUserEvent) => const onModtoolReceivedRoomsUserEvent = useCallback((event: RoomVisitsEvent) =>
{ {
const parser = event.getParser(); const parser = event.getParser();
@ -26,7 +26,7 @@ export const ModToolsUserRoomVisitsView: FC<ModToolsUserRoomVisitsViewProps> = p
setRoomVisitData(parser.data); setRoomVisitData(parser.data);
}, [userId]); }, [userId]);
CreateMessageHook(ModtoolReceivedRoomsUserEvent, onModtoolReceivedRoomsUserEvent); CreateMessageHook(RoomVisitsEvent, onModtoolReceivedRoomsUserEvent);
const RowRenderer: ListRowRenderer = (props: ListRowProps) => const RowRenderer: ListRowRenderer = (props: ListRowProps) =>
{ {