@@ -95,7 +95,7 @@ function desktopNotification (str) {
9595 * Parameters for the whole chat like its title are stored on
9696 * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
9797 */
98- export function infiniteMessageArea ( dom , kb , chatChannel , options ) {
98+ export async function infiniteMessageArea ( dom , kb , chatChannel , options ) {
9999 kb = kb || UI . store
100100 const ns = UI . ns
101101 const WF = $rdf . Namespace ( 'http://www.w3.org/2005/01/wf/flow#' )
@@ -491,11 +491,13 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
491491 async function extendBackwards ( ) {
492492 const done = await insertPreviousMessages ( true )
493493 if ( done ) {
494- scrollBackButton . firstChild . setAttribute (
495- 'src' ,
496- UI . icons . iconBase + 'noun_T-Block_1114655_000000.svg'
497- ) // T
498- scrollBackButton . disabled = true
494+ if ( scrollBackButton ) {
495+ scrollBackButton . firstChild . setAttribute (
496+ 'src' ,
497+ UI . icons . iconBase + 'noun_T-Block_1114655_000000.svg'
498+ ) // T
499+ scrollBackButton . disabled = true
500+ }
499501 messageTable . initial = true
500502 } else {
501503 messageTable . extendedBack = true
@@ -505,6 +507,9 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
505507 }
506508
507509 function setScrollBackButtonIcon ( ) {
510+ if ( ! scrollBackButton ) {
511+ return
512+ }
508513 const sense = messageTable . extendedBack ? ! newestFirst : newestFirst
509514 const scrollBackIcon = messageTable . initial
510515 ? 'noun_T-Block_1114655_000000.svg'
@@ -576,7 +581,6 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
576581 /// ///////////////////////
577582
578583 var messageTable = dom . createElement ( 'table' )
579-
580584 messageTable . extendBackwards = extendBackwards // Make function available to scroll stuff
581585 messageTable . extendForwards = extendForwards // Make function available to scroll stuff
582586 // var messageButton
@@ -586,7 +590,6 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
586590
587591 messageTable . fresh = false
588592 messageTable . setAttribute ( 'style' , 'width: 100%;' ) // fill that div!
589-
590593 if ( live ) {
591594 messageTable . final = true
592595 liveMessageTable = messageTable
@@ -823,9 +826,11 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
823826 // During initial load ONLY keep scroll to selected thing or bottom
824827 function fixScroll ( ) {
825828 if ( options . selectedElement ) {
826- options . selectedElement . scrollIntoView ( { block : 'center' } ) // allign tops or bopttoms
829+ options . selectedElement . scrollIntoView ( { block : 'center' } ) // align tops or bottoms
827830 } else {
828- liveMessageTable . inputRow . scrollIntoView ( newestFirst ) // allign tops or bopttoms
831+ if ( liveMessageTable . inputRow . scrollIntoView ) {
832+ liveMessageTable . inputRow . scrollIntoView ( newestFirst ) // align tops or bottoms
833+ }
829834 }
830835 }
831836
@@ -858,6 +863,6 @@ export function infiniteMessageArea (dom, kb, chatChannel, options) {
858863 }
859864 }
860865
861- go ( )
866+ await go ( )
862867 return div
863868}
0 commit comments