Skip to content

Commit

Permalink
fix: 修复生成战报时有回复消息的消息列表无法正常显示的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Jun 26, 2020
1 parent 2c875c6 commit 9c84b92
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 25 deletions.
19 changes: 19 additions & 0 deletions src/portal/routes/trpg/report/context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { useMemo } from 'react';
import { TMemo } from '@shared/components/TMemo';
import {
MessageItemConfigContextProvider,
MessageItemConfigPartial,
} from '@shared/components/message/MessageItemConfigContext';

export const ReportContextProvider: React.FC = TMemo((props) => {
const config = useMemo<MessageItemConfigPartial>(
() => ({ showMsgReply: false, operation: false }),
[]
);
return (
<MessageItemConfigContextProvider config={config}>
{props.children}
</MessageItemConfigContextProvider>
);
});
ReportContextProvider.displayName = 'ReportContextProvider';
5 changes: 4 additions & 1 deletion src/portal/routes/trpg/report/log-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ReportLogItem } from '@portal/model/trpg';
import { LogItem } from './log-item';
import { useSpring, animated } from 'react-spring';
import styled from 'styled-components';
import { ReportContextProvider } from './context';

const Container = styled(animated.div as any)`
user-select: none;
Expand Down Expand Up @@ -48,5 +49,7 @@ export const LogDetail: React.FC<Props> = TMemo((props) => {
[playerUUID, log, from]
);

return isShow ? logNode : null;
return (
<ReportContextProvider>{isShow ? logNode : null}</ReportContextProvider>
);
});
51 changes: 27 additions & 24 deletions src/portal/routes/trpg/report/log-edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { handleError } from '@portal/utils/error';
import history from '@portal/history';
import { LogItem } from './log-item';
import Loading from '@portal/components/Loading';
import { ReportContextProvider } from './context';

const LogEditItemContainer = styled.div`
width: 100%;
Expand Down Expand Up @@ -129,30 +130,32 @@ export const LogEdit: React.FC<LogEditProps> = TMemo((props) => {
);

return (
<div>
{logs.map((log, index) => {
return (
<LogEditItem
key={log.uuid}
log={log}
playerUUID={playerUUID}
onSelect={() => handleSelect(index)}
/>
);
})}

{logs.length > 0 ? (
<Row>
<Button onClick={showModal} block={true} style={{ marginTop: 10 }}>
生成战报
</Button>
</Row>
) : (
<Loading />
)}

{modal}
</div>
<ReportContextProvider>
<div>
{logs.map((log, index) => {
return (
<LogEditItem
key={log.uuid}
log={log}
playerUUID={playerUUID}
onSelect={() => handleSelect(index)}
/>
);
})}

{logs.length > 0 ? (
<Row>
<Button onClick={showModal} block={true} style={{ marginTop: 10 }}>
生成战报
</Button>
</Row>
) : (
<Loading />
)}

{modal}
</div>
</ReportContextProvider>
);
});
LogEdit.displayName = 'LogEdit';

0 comments on commit 9c84b92

Please sign in to comment.