Skip to content

Commit 8841bac

Browse files
committed
feat(web): merge back to back messages from the same author
1 parent 8db88ac commit 8841bac

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

packages/ui/src/components/pages/MessageResultPage.stories.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,61 @@ export const PrivateSolution: Story = {
182182
],
183183
},
184184
};
185+
186+
export const ManyFromSameAuthor: Story = {
187+
args: {
188+
...defaultMessage,
189+
messages: [
190+
mockMessageWithDiscordAccount({
191+
id: '1',
192+
solutionIds: ['4'],
193+
public: true,
194+
author: {
195+
id: '1',
196+
name: 'John Doe',
197+
avatar: 'https://cdn.discordapp.com/embed/avatars/0.png',
198+
},
199+
}),
200+
mockMessageWithDiscordAccount({
201+
id: '2',
202+
public: true,
203+
author: {
204+
id: '1',
205+
name: 'John Doe',
206+
avatar: 'https://cdn.discordapp.com/embed/avatars/0.png',
207+
},
208+
}),
209+
mockMessageWithDiscordAccount({
210+
id: '3',
211+
public: true,
212+
}),
213+
mockMessageWithDiscordAccount({
214+
id: '4',
215+
public: false,
216+
author: {
217+
id: '1',
218+
name: 'John Doe',
219+
avatar: 'https://cdn.discordapp.com/embed/avatars/0.png',
220+
},
221+
}),
222+
mockMessageWithDiscordAccount({
223+
id: '5',
224+
public: true,
225+
author: {
226+
id: '1',
227+
name: 'John Doe',
228+
avatar: 'https://cdn.discordapp.com/embed/avatars/0.png',
229+
},
230+
}),
231+
mockMessageWithDiscordAccount({
232+
id: '6',
233+
public: true,
234+
author: {
235+
id: '1',
236+
name: 'John Doe',
237+
avatar: 'https://cdn.discordapp.com/embed/avatars/0.png',
238+
},
239+
}),
240+
],
241+
},
242+
};

packages/ui/src/components/pages/MessageResultPage.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ export function MessageResultPage({
8686
)
8787
return null;
8888

89+
if (message.author.id === nextMessage?.author.id) {
90+
nextMessage.content += `\n${message.content}`;
91+
return;
92+
}
93+
8994
const Msg = ({ count }: { count: number }) => (
9095
<Message
9196
key={message.id}

packages/ui/src/components/primitives/Message.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ export const Message = ({
253253
<Blurrer>
254254
<div
255255
className={cn(
256-
`discord-message grow bg-[#E9ECF2] dark:bg-[#181B1F] ${
256+
`discord-message grow bg-[#E9ECF2] leading-6 dark:bg-[#181B1F] ${
257257
showBorders ? 'border-2' : ''
258258
} border-black/[.13] dark:border-white/[.13] ${
259259
fullRounded ? 'rounded-standard' : 'lg:rounded-tl-standard'

0 commit comments

Comments
 (0)