Skip to content

Commit

Permalink
Reduce updates when showing item lists; add a waiting spinner
Browse files Browse the repository at this point in the history
When loading long pages with sorts, sometimes the initial page number
shown in the bottom pagination bar was wrong.  This fixes that issue.
  • Loading branch information
manthey committed Sep 27, 2024
1 parent 895c3c7 commit 133de0c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Better handle images without enough tile layers ([#1648](../../pull/1648))
- Add users option to config files; have a default config file ([#1649](../../pull/1649))
- Remove no longer used code; adjust item list slightly ([#1651](../../pull/1651))
- Reduce updates when showing item lists; add a waiting spinner ([#1653](../../pull/1653))

### Bug Fixes

Expand Down
23 changes: 19 additions & 4 deletions girder/girder_large_image/web_client/views/itemList.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ wrap(FolderListWidget, 'checkAll', function (checkAll, checked) {
});

wrap(ItemListWidget, 'initialize', function (initialize, settings) {
this._inInit = true;
const result = initialize.call(this, settings);
delete this._hasAnyLargeImage;

Expand All @@ -54,6 +55,8 @@ wrap(ItemListWidget, 'initialize', function (initialize, settings) {
this._liconfig = val;
}
if (_.isEqual(val, this._liconfig) && !this._recurse) {
this._inInit = false;
this.render();

Check warning on line 59 in girder/girder_large_image/web_client/views/itemList.js

View check run for this annotation

Codecov / codecov/patch

girder/girder_large_image/web_client/views/itemList.js#L58-L59

Added lines #L58 - L59 were not covered by tests
return;
}
delete this._lastSort;
Expand All @@ -74,12 +77,14 @@ wrap(ItemListWidget, 'initialize', function (initialize, settings) {
update = true;
} else if (this._confList() && this._confList().defaultSort && this._confList().defaultSort.length) {
this._lastSort = this._confList().defaultSort;
update = true;
}
if (query.filter || this._recurse) {
this._generalFilter = query.filter;
this._setFilter(false);
update = true;
}
this._inInit = false;
if (update) {
this._setSort();
} else {
Expand All @@ -104,6 +109,9 @@ wrap(ItemListWidget, 'initialize', function (initialize, settings) {

wrap(ItemListWidget, 'render', function (render) {
this.$el.closest('.modal-dialog').addClass('li-item-list-dialog');
if (!this.$el.children().length) {
this.$el.html('<span class="icon-spin1 animate-spin" title="Loading item list"/>');
}

/* Chrome limits the number of connections to a single domain, which means
* that time-consuming requests for thumbnails can bind-up the web browser.
Expand Down Expand Up @@ -155,12 +163,16 @@ wrap(ItemListWidget, 'render', function (render) {
const pages = Math.ceil(this.collection.getTotalCount() / this.collection.pageLimit);
this._totalPages = pages;
this._inFetch = false;
if (this._needsFetch) {
this._setSort();
}
if (oldPages !== pages) {
itemListRender.apply(this, _.rest(arguments));
if (oldPages !== pages || this.collection.offset !== this.collection.size()) {
this.collection.offset = this.collection.size();

Check warning on line 168 in girder/girder_large_image/web_client/views/itemList.js

View check run for this annotation

Codecov / codecov/patch

girder/girder_large_image/web_client/views/itemList.js#L168

Added line #L168 was not covered by tests
this.trigger('g:paginated');
this.collection.trigger('g:changed');
} else {
itemListRender.apply(this, _.rest(arguments));
}
if (this._needsFetch) {
this._setSort();

Check warning on line 175 in girder/girder_large_image/web_client/views/itemList.js

View check run for this annotation

Codecov / codecov/patch

girder/girder_large_image/web_client/views/itemList.js#L175

Added line #L175 was not covered by tests
}
});
} else {
Expand Down Expand Up @@ -300,6 +312,9 @@ wrap(ItemListWidget, 'render', function (render) {
};

function itemListRender() {
if (this._inInit || this._inFetch) {
return;
}
const root = this.$el.closest('.g-hierarchy-widget');
if (!root.find('.li-item-list-filter').length) {
let base = root.find('.g-hierarchy-actions-header .g-folder-header-buttons').eq(0);
Expand Down

0 comments on commit 133de0c

Please sign in to comment.