mirror of
https://github.com/urbit/shrub.git
synced 2024-12-18 15:55:00 +03:00
Merge pull request #3023 from urbit/lf/chat-max-backlog
chat: qol fixes
This commit is contained in:
commit
d5d25140f1
@ -22,6 +22,7 @@ function getNumPending(props) {
|
|||||||
|
|
||||||
const ACTIVITY_TIMEOUT = 60000; // a minute
|
const ACTIVITY_TIMEOUT = 60000; // a minute
|
||||||
const DEFAULT_BACKLOG_SIZE = 300;
|
const DEFAULT_BACKLOG_SIZE = 300;
|
||||||
|
const MAX_BACKLOG_SIZE = 1000;
|
||||||
|
|
||||||
function scrollIsAtTop(container) {
|
function scrollIsAtTop(container) {
|
||||||
if ((navigator.userAgent.includes("Safari") &&
|
if ((navigator.userAgent.includes("Safari") &&
|
||||||
@ -136,14 +137,15 @@ export class ChatScreen extends Component {
|
|||||||
|
|
||||||
const unread = props.length - props.read;
|
const unread = props.length - props.read;
|
||||||
const unreadUnloaded = unread - props.envelopes.length;
|
const unreadUnloaded = unread - props.envelopes.length;
|
||||||
|
const excessUnread = unreadUnloaded > MAX_BACKLOG_SIZE;
|
||||||
|
|
||||||
if(unreadUnloaded + 20 > DEFAULT_BACKLOG_SIZE) {
|
if(!excessUnread && unreadUnloaded + 20 > DEFAULT_BACKLOG_SIZE) {
|
||||||
this.askForMessages(unreadUnloaded + 20);
|
this.askForMessages(unreadUnloaded + 20);
|
||||||
} else {
|
} else {
|
||||||
this.askForMessages(DEFAULT_BACKLOG_SIZE);
|
this.askForMessages(DEFAULT_BACKLOG_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(props.read === props.length){
|
if(excessUnread || props.read === props.length){
|
||||||
this.scrolledToMarker = true;
|
this.scrolledToMarker = true;
|
||||||
this.setState(
|
this.setState(
|
||||||
{
|
{
|
||||||
|
@ -87,8 +87,8 @@ export class Message extends Component {
|
|||||||
className="o-80-d"
|
className="o-80-d"
|
||||||
src={letter.url}
|
src={letter.url}
|
||||||
style={{
|
style={{
|
||||||
width: '50%',
|
height: 'min(250px, 20vh)',
|
||||||
maxWidth: '250px'
|
maxWidth: '80vw'
|
||||||
}}
|
}}
|
||||||
></img>
|
></img>
|
||||||
);
|
);
|
||||||
@ -154,7 +154,7 @@ export class Message extends Component {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<section>
|
<section className="chat-md-message">
|
||||||
<MessageMarkdown
|
<MessageMarkdown
|
||||||
source={letter.text}
|
source={letter.text}
|
||||||
/>
|
/>
|
||||||
|
@ -60,6 +60,10 @@ h2 {
|
|||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-md-message > pre {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.mono {
|
.mono {
|
||||||
font-family: "Source Code Pro", monospace;
|
font-family: "Source Code Pro", monospace;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user