diff options
author | Mario <mario@mariovavti.com> | 2023-07-20 19:20:56 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2023-07-20 19:20:56 +0000 |
commit | 8da6e6a096c7cb5ab8aa7c4b30d69c4876810a84 (patch) | |
tree | a30bcc84000d6b6cc6673b766771a7f93ce98ae5 /view | |
parent | 5181e575b4eb91de3ec71a125d45c29e65372c76 (diff) | |
download | volse-hubzilla-8da6e6a096c7cb5ab8aa7c4b30d69c4876810a84.tar.gz volse-hubzilla-8da6e6a096c7cb5ab8aa7c4b30d69c4876810a84.tar.bz2 volse-hubzilla-8da6e6a096c7cb5ab8aa7c4b30d69c4876810a84.zip |
move trigger out of the loop for better performance and some var -> let
Diffstat (limited to 'view')
-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) { |