Skip to content

Commit 6bcaf83

Browse files
committed
ternary instead of different component
1 parent 4a04e6d commit 6bcaf83

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

redisinsight/ui/src/pages/pub-sub/components/publish-message/PublishMessage.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@ import { ChannelColumn } from './PublishMessage.styles'
2020

2121
const HIDE_BADGE_TIMER = 3000
2222

23-
const PublishedMessages = ({ clients }: { clients: number | undefined }) => {
24-
if (typeof clients !== 'number') {
25-
return <Text color="success">Published</Text>
26-
}
27-
28-
return <Text color="success">Published ({clients})</Text>
29-
}
30-
3123
const PublishMessage = () => {
3224
const { channel: channelContext, message: messageContext } =
3325
useSelector(appContextPubSub)
@@ -80,6 +72,9 @@ const PublishMessage = () => {
8072
dispatch(publishMessageAction(instanceId, channel, message, onSuccess))
8173
}
8274

75+
const getClientsText = (clients?: number) =>
76+
typeof clients !== 'number' ? 'Published' : `Published (${clients})`
77+
8378
return (
8479
<form onSubmit={onFormSubmit}>
8580
<Row justify="between" gap="xl" align="end">
@@ -120,13 +115,13 @@ const PublishMessage = () => {
120115
{isShowBadge && (
121116
<Row grow={false} style={{ minHeight: 36 }} align="center">
122117
<Icon icon={ToastCheckIcon} color="success500" />
123-
<PublishedMessages
124-
clients={
118+
<Text color="success">
119+
{getClientsText(
125120
connectionType !== ConnectionType.Cluster
126121
? affectedClients
127-
: undefined
128-
}
129-
/>
122+
: undefined,
123+
)}
124+
</Text>
130125
</Row>
131126
)}
132127

0 commit comments

Comments
 (0)