mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
fix(mod-tools): chatlog wrappers back to useMessageEvent + useEffect
ModToolsChatlogView and CfhChatlogView were on the useNitroQuery pattern. Symptom: the card opens, the spinner spins, but the data never arrives — even when the server is correctly answering with ModToolRoomChatlogComposer (header 3434) and GetCfhChatlogComposer (607). Both header IDs match the renderer's Incoming map, both server handlers gate only on ACC_SUPPORTTOOL and reply unconditionally when the room/issue lookup succeeds. So the request DOES go out and the response DOES come back — but useNitroQuery's listener (registered via `new (ParserCtor)(callback)` + `registerMessageEvent`) isn't delivering the event to the React side here. ModToolsUserChatlogView already uses the plain `useMessageEvent` + `useEffect(sendComposer)` pattern and works on this same setup, so align the two broken views with it. Keep the loading-spinner empty state introduced yesterday so the user still gets visible feedback while the response is in flight. This sidesteps useNitroQuery for these two cases rather than fixing it in place — the underlying createNitroQuery + listener registration plumbing still works for OfferView, useUserGroups, useClubOffers, useSellablePetPalette, useMarketplaceConfiguration, useClubGifts, CatalogLayoutRoomAdsView, so the regression is specific to these two parsers and worth investigating separately. Filed as a follow-up.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { ChatRecordData, GetRoomChatlogMessageComposer, RoomChatlogEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { FaSpinner } from 'react-icons/fa';
|
||||
import { LocalizeText } from '../../../../api';
|
||||
import { useNitroQuery } from '../../../../api/nitro-query';
|
||||
import { LocalizeText, SendMessageComposer } from '../../../../api';
|
||||
import { DraggableWindowPosition, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common';
|
||||
import { useMessageEvent } from '../../../../hooks';
|
||||
import { ChatlogView } from '../chatlog/ChatlogView';
|
||||
|
||||
interface ModToolsChatlogViewProps
|
||||
@@ -15,16 +15,22 @@ interface ModToolsChatlogViewProps
|
||||
export const ModToolsChatlogView: FC<ModToolsChatlogViewProps> = props =>
|
||||
{
|
||||
const { roomId = null, onCloseClick = null } = props;
|
||||
const [ roomChatlog, setRoomChatlog ] = useState<ChatRecordData>(null);
|
||||
|
||||
const { data: roomChatlog } = useNitroQuery<RoomChatlogEvent, ChatRecordData>({
|
||||
key: [ 'nitro', 'mod-tools', 'room-chatlog', roomId ],
|
||||
request: () => new GetRoomChatlogMessageComposer(roomId),
|
||||
parser: RoomChatlogEvent,
|
||||
accept: e => e.getParser()?.data.roomId === roomId,
|
||||
select: e => e.getParser().data,
|
||||
enabled: roomId !== null
|
||||
useMessageEvent<RoomChatlogEvent>(RoomChatlogEvent, event =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser || parser.data.roomId !== roomId) return;
|
||||
|
||||
setRoomChatlog(parser.data);
|
||||
});
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
SendMessageComposer(new GetRoomChatlogMessageComposer(roomId));
|
||||
}, [ roomId ]);
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-mod-tools-chatlog min-w-[460px] max-w-[520px] max-h-[500px]" theme="primary-slim" windowPosition={ DraggableWindowPosition.TOP_LEFT }>
|
||||
<NitroCardHeaderView headerText={ LocalizeText('modtools.room.chatlog.title') } onCloseClick={ onCloseClick } />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { CfhChatlogData, CfhChatlogEvent, GetCfhChatlogMessageComposer } from '@nitrots/nitro-renderer';
|
||||
import { FC } from 'react';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { FaSpinner } from 'react-icons/fa';
|
||||
import { LocalizeText } from '../../../../api';
|
||||
import { useNitroQuery } from '../../../../api/nitro-query';
|
||||
import { LocalizeText, SendMessageComposer } from '../../../../api';
|
||||
import { DraggableWindowPosition, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common';
|
||||
import { useMessageEvent } from '../../../../hooks';
|
||||
import { ChatlogView } from '../chatlog/ChatlogView';
|
||||
|
||||
interface CfhChatlogViewProps
|
||||
@@ -15,16 +15,22 @@ interface CfhChatlogViewProps
|
||||
export const CfhChatlogView: FC<CfhChatlogViewProps> = props =>
|
||||
{
|
||||
const { onCloseClick = null, issueId = null } = props;
|
||||
const [ chatlogData, setChatlogData ] = useState<CfhChatlogData>(null);
|
||||
|
||||
const { data: chatlogData } = useNitroQuery<CfhChatlogEvent, CfhChatlogData>({
|
||||
key: [ 'nitro', 'mod-tools', 'cfh-chatlog', issueId ],
|
||||
request: () => new GetCfhChatlogMessageComposer(issueId),
|
||||
parser: CfhChatlogEvent,
|
||||
accept: e => e.getParser()?.data.issueId === issueId,
|
||||
select: e => e.getParser().data,
|
||||
enabled: issueId !== null
|
||||
useMessageEvent<CfhChatlogEvent>(CfhChatlogEvent, event =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser || parser.data.issueId !== issueId) return;
|
||||
|
||||
setChatlogData(parser.data);
|
||||
});
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
SendMessageComposer(new GetCfhChatlogMessageComposer(issueId));
|
||||
}, [ issueId ]);
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-mod-tools-chatlog min-w-[460px] max-w-[520px] max-h-[500px]" theme="primary-slim" windowPosition={ DraggableWindowPosition.TOP_LEFT }>
|
||||
<NitroCardHeaderView headerText={ LocalizeText('modtools.tickets.cfh.chatlog.title', [ 'issueId' ], [ issueId.toString() ]) } onCloseClick={ onCloseClick } />
|
||||
|
||||
Reference in New Issue
Block a user