chat: lazier chat loading

Load smaller amounts of backlog when displaying a chat
This commit is contained in:
Liam Fitzgerald 2020-12-14 15:15:30 +10:00
parent 8b83df00bd
commit 51a4816978
No known key found for this signature in database
GPG Key ID: D390E12C61D1CFFB
2 changed files with 3 additions and 4 deletions

View File

@ -38,8 +38,7 @@ export function ChatResource(props: ChatResourceProps) {
const chatInput = useRef<ChatInput>();
useEffect(() => {
const count = Math.min(150, unreadCount + 30);
console.log(`fetching ${count}`);
const count = Math.min(50, unreadCount + 15);
props.api.graph.getNewest(owner, name, count);
}, [station]);

View File

@ -199,14 +199,14 @@ export default class ChatWindow extends Component<ChatWindowProps, ChatWindowSta
const currSize = graph.size;
if(newer && !this.loadedNewest) {
const [index] = graph.peekLargest()!;
await api.graph.getYoungerSiblings(ship,name, 100, `/${index.toString()}`)
await api.graph.getYoungerSiblings(ship,name, 20, `/${index.toString()}`)
if(currSize === graph.size) {
console.log('loaded all newest');
this.loadedNewest = true;
}
} else if(!newer && !this.loadedOldest) {
const [index] = graph.peekSmallest()!;
await api.graph.getOlderSiblings(ship,name, 100, `/${index.toString()}`)
await api.graph.getOlderSiblings(ship,name, 20, `/${index.toString()}`)
this.calculateUnreadIndex();
if(currSize === graph.size) {
console.log('loaded all oldest');