diff options
author | Mario <mario@mariovavti.com> | 2023-07-20 19:20:56 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-08-27 17:49:52 +0000 |
commit | 0b20069c2040dd67522ee076195bf82e218dbd80 (patch) | |
tree | ba0678b44a1f26ac3727d9fb04004f424f1a77d2 | |
parent | f89ce939409b5832c1a85cae011b027cc8579ef1 (diff) | |
download | volse-hubzilla-0b20069c2040dd67522ee076195bf82e218dbd80.tar.gz volse-hubzilla-0b20069c2040dd67522ee076195bf82e218dbd80.tar.bz2 volse-hubzilla-0b20069c2040dd67522ee076195bf82e218dbd80.zip |
move trigger out of the loop for better performance and some var -> let
-rw-r--r-- | view/js/main.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/view/js/main.js b/view/js/main.js index 9c2480795..13fc29cd4 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -646,7 +646,8 @@ function updatePageItems(mode, data) { function updateConvItems(mode,data) { - var scroll_position = $(window).scrollTop(); + let scroll_position = $(window).scrollTop(); + let b64mids = []; if(mode !== 'update') $(document).trigger('hz:updateConvItems'); @@ -660,12 +661,12 @@ function updateConvItems(mode,data) { $('.thread-wrapper', data).each(function() { if(this.classList.contains('toplevel_item')) { - var ident = this.id; - var convId = ident.replace('thread-wrapper-',''); - var commentWrap = $('#'+ident+' .collapsed-comments').attr('id'); + let ident = this.id; + let convId = ident.replace('thread-wrapper-',''); + let commentWrap = $('#'+ident+' .collapsed-comments').attr('id'); - var itmId = 0; - var isVisible = false; + let itmId = 0; + let isVisible = false; // figure out the comment state if(typeof commentWrap !== 'undefined') @@ -695,7 +696,7 @@ function updateConvItems(mode,data) { if(isVisible) showHideComments(itmId); - var commentBody = localStorage.getItem("comment_body-" + convId); + let commentBody = localStorage.getItem("comment_body-" + convId); if(commentBody) { var commentElm = $('#comment-edit-text-' + convId); @@ -723,7 +724,7 @@ function updateConvItems(mode,data) { if(mode === 'replace') { if (window.location.search.indexOf("mid=") != -1 || window.location.pathname.indexOf("display") != -1) { - var title = $(".wall-item-title").text(); + let title = $(".wall-item-title").text(); title.replace(/^\s+/, ''); title.replace(/\s+$/, ''); if (title) { @@ -734,10 +735,14 @@ function updateConvItems(mode,data) { } } - $(document).trigger('hz:sse_setNotificationsStatus', [$(this).data('b64mids')]); + $(this).data('b64mids').forEach((b64mid) => { + b64mids.push(b64mid); + }); }); + $(document).trigger('hz:sse_setNotificationsStatus', [b64mids]); + $(window).scrollTop(scroll_position); if(followUpPageLoad) { |