mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Improve chat text overflow. Graceful overflow without whitespaces.
This commit is contained in:
parent
34a5340e06
commit
191a043303
@ -49,16 +49,8 @@ class ChatRoomConsumer(AsyncWebsocketConsumer):
|
||||
message = event["message"]
|
||||
nick = event["nick"]
|
||||
|
||||
# Insert a white space in words longer than 22 characters.
|
||||
# Helps when messages overflow in a single line.
|
||||
words = message.split(" ")
|
||||
fix_message = ""
|
||||
for word in words:
|
||||
word = " ".join(word[i:i + 22] for i in range(0, len(word), 22))
|
||||
fix_message = fix_message + " " + word
|
||||
|
||||
await self.send(text_data=json.dumps({
|
||||
"message": fix_message,
|
||||
"message": message,
|
||||
"user_nick": nick,
|
||||
}))
|
||||
|
||||
|
@ -67,7 +67,7 @@ export default class Chat extends Component {
|
||||
<Card elevation={5} align="left" >
|
||||
{/* If message sender is not our nick, gray color, if it is our nick, green color */}
|
||||
{message.userNick == this.props.ur_nick ?
|
||||
<CardHeader
|
||||
<CardHeader
|
||||
avatar={
|
||||
<Avatar
|
||||
alt={message.userNick}
|
||||
@ -77,19 +77,21 @@ export default class Chat extends Component {
|
||||
style={{backgroundColor: '#e8ffe6'}}
|
||||
title={message.userNick}
|
||||
subheader={message.msg}
|
||||
subheaderTypographyProps={{sx: {wordWrap: "break-word", width: 200}}}
|
||||
/>
|
||||
:
|
||||
<CardHeader
|
||||
avatar={
|
||||
<Avatar
|
||||
alt={message.userNick}
|
||||
src={window.location.origin +'/static/assets/avatars/' + message.userNick + '.png'}
|
||||
/>
|
||||
}
|
||||
style={{backgroundColor: '#fcfcfc'}}
|
||||
title={message.userNick}
|
||||
subheader={message.msg}
|
||||
/>}
|
||||
avatar={
|
||||
<Avatar
|
||||
alt={message.userNick}
|
||||
src={window.location.origin +'/static/assets/avatars/' + message.userNick + '.png'}
|
||||
/>
|
||||
}
|
||||
style={{backgroundColor: '#fcfcfc'}}
|
||||
title={message.userNick}
|
||||
subheader={message.msg}
|
||||
subheaderTypographyProps={{sx: {wordWrap: "break-word", width: 200}}}
|
||||
/>}
|
||||
</Card>
|
||||
</>)}
|
||||
<div style={{ float:"left", clear: "both" }} ref={(el) => { this.messagesEnd = el; }}></div>
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user