aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-07-21 09:09:41 +0000
committerMario <mario@mariovavti.com>2020-07-21 09:09:41 +0000
commit62eebc86f6665ffb10f0d5f774b8a1d50442073d (patch)
tree21f08907b6d26238c5fd4ba7916377af21262e0f /view/js
parentfcc47e69e424635fa54b2684329623d4f7694436 (diff)
downloadvolse-hubzilla-62eebc86f6665ffb10f0d5f774b8a1d50442073d.tar.gz
volse-hubzilla-62eebc86f6665ffb10f0d5f774b8a1d50442073d.tar.bz2
volse-hubzilla-62eebc86f6665ffb10f0d5f774b8a1d50442073d.zip
no need to iterate the object twice
Diffstat (limited to 'view/js')
-rw-r--r--view/js/main.js117
1 files changed, 56 insertions, 61 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 82de0d06f..fa5300d54 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -627,89 +627,84 @@ function updateConvItems(mode,data) {
$('.thread-wrapper').remove(); // clear existing content
}
- $('.thread-wrapper.toplevel_item',data).each(function() {
-
- var ident = $(this).attr('id');
- var convId = ident.replace('thread-wrapper-','');
- var commentWrap = $('#'+ident+' .collapsed-comments').attr('id');
-
-
- var itmId = 0;
- var isVisible = false;
+ $('.thread-wrapper', data).each(function() {
+ if(this.classList.contains('toplevel_item')) {
- // figure out the comment state
- if(typeof commentWrap !== 'undefined')
- itmId = commentWrap.replace('collapsed-comments-','');
-
- if($('#collapsed-comments-'+itmId).is(':visible'))
- isVisible = true;
+ var ident = this.id;
+ var convId = ident.replace('thread-wrapper-','');
+ var commentWrap = $('#'+ident+' .collapsed-comments').attr('id');
+ var itmId = 0;
+ var isVisible = false;
+ // figure out the comment state
+ if(typeof commentWrap !== 'undefined')
+ itmId = commentWrap.replace('collapsed-comments-','');
+ if($('#collapsed-comments-'+itmId).is(':visible'))
+ isVisible = true;
- // insert the content according to the mode and first_page
- // and whether or not the content exists already (overwrite it)
+ // insert the content according to the mode and first_page
+ // and whether or not the content exists already (overwrite it)
- if($('#' + ident).length == 0) {
- if((mode === 'update' || mode === 'replace') && profile_page == 1) {
- $('#' + prev).after($(this));
- prev = ident;
+ if($('#' + ident).length == 0) {
+ if((mode === 'update' || mode === 'replace') && profile_page == 1) {
+ $('#' + prev).after($(this));
+ prev = ident;
+ }
+ if(mode === 'append') {
+ $('#' + next).before($(this));
+ }
}
- if(mode === 'append') {
- $('#' + next).before($(this));
+ else {
+ $('#' + ident).replaceWith($(this));
}
- }
- else {
- $('#' + ident).replaceWith($(this));
- }
- // set the comment state to the state we discovered earlier
+ // set the comment state to the state we discovered earlier
- if(isVisible)
- showHideComments(itmId);
+ if(isVisible)
+ showHideComments(itmId);
- var commentBody = localStorage.getItem("comment_body-" + convId);
+ var commentBody = localStorage.getItem("comment_body-" + convId);
- if(commentBody) {
- var commentElm = $('#comment-edit-text-' + convId);
- if(auto_save_draft) {
- if($(commentElm).val() === '') {
- $('#comment-edit-form-' + convId).show();
- $(commentElm).addClass("expanded");
- openMenu("comment-tools-" + convId);
- $(commentElm).val(commentBody);
+ if(commentBody) {
+ var commentElm = $('#comment-edit-text-' + convId);
+ if(auto_save_draft) {
+ if($(commentElm).val() === '') {
+ $('#comment-edit-form-' + convId).show();
+ $(commentElm).addClass("expanded");
+ openMenu("comment-tools-" + convId);
+ $(commentElm).val(commentBody);
+ }
+ } else {
+ localStorage.removeItem("comment_body-" + convId);
}
- } else {
- localStorage.removeItem("comment_body-" + convId);
}
- }
- // trigger the autotime function on all newly created content
- $("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
- $("> .shared_header .autotime",this).timeago();
+ // trigger the autotime function on all newly created content
+ $("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
- if((mode === 'append' || mode === 'replace') && (loadingPage)) {
- loadingPage = false;
- }
+ if((mode === 'append' || mode === 'replace') && (loadingPage)) {
+ loadingPage = false;
+ }
- // if single thread view and the item has a title, display it in the title bar
+ // if single thread view and the item has a title, display it in the title bar
- if(mode === 'replace') {
- if (window.location.search.indexOf("mid=") != -1 || window.location.pathname.indexOf("display") != -1) {
- var title = $(".wall-item-title").text();
- title.replace(/^\s+/, '');
- title.replace(/\s+$/, '');
- if (title) {
- savedTitle = title + " " + savedTitle;
- document.title = title;
+ if(mode === 'replace') {
+ if (window.location.search.indexOf("mid=") != -1 || window.location.pathname.indexOf("display") != -1) {
+ var title = $(".wall-item-title").text();
+ title.replace(/^\s+/, '');
+ title.replace(/\s+$/, '');
+ if (title) {
+ savedTitle = title + " " + savedTitle;
+ document.title = title;
+ }
}
}
}
- });
-
- // take care of the notifications count updates
- $('.thread-wrapper', data).each(function() {
+ // take care of the notifications count updates
var nmids = $(this).data('b64mids');
nmids.forEach(function(nmid, index) {