(options = {})
| 594 | } |
| 595 | |
| 596 | function renderMessageList(options = {}) { |
| 597 | const currentToken = ++renderToken; |
| 598 | const connection = state.connections[state.selectedConnectionId]; |
| 599 | |
| 600 | if (!connection || connection.messages.length === 0) { |
| 601 | elements$6.messageTbody.innerHTML = ''; |
| 602 | elements$6.messageEmpty.style.display = 'flex'; |
| 603 | elements$6.messageTbody.parentElement.style.display = 'none'; |
| 604 | lastRenderedConnectionId = null; |
| 605 | lastRenderedMessageCount = 0; |
| 606 | lastRenderSignature = ''; |
| 607 | return; |
| 608 | } |
| 609 | |
| 610 | elements$6.messageEmpty.style.display = 'none'; |
| 611 | elements$6.messageTbody.parentElement.style.display = 'flex'; |
| 612 | |
| 613 | const filteredMessages = getFilteredMessages(connection); |
| 614 | |
| 615 | updateFilterStats(filteredMessages.length, connection.messages.length); |
| 616 | |
| 617 | const displayMessages = getDisplayMessages(filteredMessages); |
| 618 | |
| 619 | const currentConnectionId = state.selectedConnectionId; |
| 620 | const currentMessageCount = displayMessages.length; |
| 621 | const currentRenderSignature = getRenderSignature(currentConnectionId); |
| 622 | |
| 623 | const isConnectionChanged = currentConnectionId !== lastRenderedConnectionId; |
| 624 | const isRenderStateChanged = currentRenderSignature !== lastRenderSignature; |
| 625 | const isMessageCountReduced = currentMessageCount < lastRenderedMessageCount; |
| 626 | const shouldFullRender = options.force || |
| 627 | isConnectionChanged || |
| 628 | isRenderStateChanged || |
| 629 | isMessageCountReduced; |
| 630 | |
| 631 | if (renderTimeout) { |
| 632 | cancelAnimationFrame(renderTimeout); |
| 633 | } |
| 634 | |
| 635 | renderTimeout = requestAnimationFrame(() => { |
| 636 | if (currentToken !== renderToken || currentConnectionId !== state.selectedConnectionId) { |
| 637 | return; |
| 638 | } |
| 639 | |
| 640 | if (shouldFullRender) { |
| 641 | renderAllMessages(displayMessages); |
| 642 | } else { |
| 643 | const isAutoScrolling = state.autoScrollToBottom && |
| 644 | elements$6.messageTbody.scrollTop + elements$6.messageTbody.clientHeight >= elements$6.messageTbody.scrollHeight - 50; |
| 645 | |
| 646 | renderIncrementalMessages(displayMessages, lastRenderedMessageCount, isAutoScrolling); |
| 647 | } |
| 648 | |
| 649 | lastRenderedConnectionId = currentConnectionId; |
| 650 | lastRenderedMessageCount = currentMessageCount; |
| 651 | lastRenderSignature = currentRenderSignature; |
| 652 | }); |
| 653 | } |
no test coverage detected