Merge pull request #3512 from tylershuster/backlog-height

chat: make backlog height only reflect loaded messages
This commit is contained in:
matildepark 2020-09-18 21:03:27 -04:00 committed by GitHub
commit c19acbb041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 8 deletions

View File

@ -20,6 +20,7 @@ import { BacklogElement } from "./backlog-element";
const INITIAL_LOAD = 20;
const DEFAULT_BACKLOG_SIZE = 100;
const IDLE_THRESHOLD = 64;
const MAX_BACKLOG_SIZE = 1000;
type ChatWindowProps = RouteComponentProps<{
ship: Patp;
@ -188,8 +189,11 @@ export default class ChatWindow extends Component<ChatWindowProps, ChatWindowSta
this.setState({ fetchPending: true });
start = Math.min(mailboxSize - start, mailboxSize);
end = Math.max(mailboxSize - end, 0, start - MAX_BACKLOG_SIZE);
return api.chat
.fetchMessages(Math.max(mailboxSize - end, 0), Math.min(mailboxSize - start, mailboxSize), station)
.fetchMessages(end, start, station)
.finally(() => {
this.setState({ fetchPending: false });
});

View File

@ -150,7 +150,7 @@ export default class VirtualScroller extends PureComponent<VirtualScrollerProps,
}
});
endgap += Math.abs(totalSize - data.size) * averageHeight;
// endgap += Math.abs(totalSize - data.size) * averageHeight; // Uncomment to make full height of backlog
startBuffer = new Map([...startBuffer].reverse().slice(0, visibleItems.size));
startBuffer.forEach((datum, index) => {