Skip to content

Commit

Permalink
fixes for message loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Aug 26, 2023
1 parent c5a7ff2 commit 17ef8d7
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions src/components/messaging/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,32 +62,35 @@ function MessageList({ guild, channel }: Props) {

return (
<Container id="scrollable-div">
<InfiniteScroll
dataLength={channel.messages.grouped.length}
next={fetchMore}
style={{ display: "flex", flexDirection: "column-reverse" }} // to put endMessage and loader to the top.
hasMore={hasMore}
loader={
<PulseLoader
style={{ display: "flex", justifyContent: "center", alignContent: "center" }}
color="var(--primary)"
/>
}
scrollableTarget="scrollable-div"
endMessage={
<EndMessageContainer>
<h1 style={{ fontWeight: 700, margin: "8px 0" }}>Welcome to #{channel.name}!</h1>
<p style={{ color: "var(--text-secondary)" }}>
This is the start of the #{channel.name} channel.
</p>
<HorizontalDivider />
</EndMessageContainer>
}
>
{channel.messages.grouped.map((group, index) => {
return <MessageGroup key={index} messages={group} />;
})}
</InfiniteScroll>
{channel.messages.count === 0 ? (
<PulseLoader style={{ display: "flex", justifyContent: "center" }} color="var(--primary)" />
) : (
<>
<InfiniteScroll
dataLength={channel.messages.grouped.length}
next={fetchMore}
style={{ display: "flex", flexDirection: "column-reverse" }} // to put endMessage and loader to the top.
hasMore={hasMore}
loader={
<PulseLoader style={{ display: "flex", justifyContent: "center" }} color="var(--primary)" />
}
scrollableTarget="scrollable-div"
endMessage={
<EndMessageContainer>
<h1 style={{ fontWeight: 700, margin: "8px 0" }}>Welcome to #{channel.name}!</h1>
<p style={{ color: "var(--text-secondary)" }}>
This is the start of the #{channel.name} channel.
</p>
<HorizontalDivider />
</EndMessageContainer>
}
>
{channel.messages.grouped.map((group, index) => {
return <MessageGroup key={index} messages={group} />;
})}
</InfiniteScroll>
</>
)}
</Container>
);
}
Expand Down

0 comments on commit 17ef8d7

Please sign in to comment.