[IMP] web_editor: load more illustrations only when filter is set
Before this commit, clicking on the 'load more' button of the media dialog after a search (with no filter set) would load more attachments/illustrations/unsplash records. As illustrations are considered less relevant than attachments/unsplash records, it was decided to load more of them only when the filter is set to "illustrations". When the filter is not set, the 'load more' button will be visible only if there are more attachments or more unsplash images to load (and not visible otherwise, even if there are more illustrations to load). Also, the loadMore override will only perform the query to load more illustrations if the filter is set. A deeper review of the Media Dialog UI will be conducted later. For now, this commit avoids loading too many illustrations, for users that are most of the time more interested in the unsplash results. task-3060679 X-original-commit: 6aaca71a4b2a11ffa80578904bc7c79c1fa0339d Part-of: odoo/odoo#118556
This commit is contained in:
@@ -68,9 +68,8 @@ export class ImageSelector extends FileSelector {
|
||||
}
|
||||
|
||||
get canLoadMore() {
|
||||
if (this.state.searchService === 'all') {
|
||||
return super.canLoadMore || (this.state.libraryResults && this.state.libraryMedia.length < this.state.libraryResults);
|
||||
} else if (this.state.searchService === 'media-library') {
|
||||
// The user can load more library media only when the filter is set.
|
||||
if (this.state.searchService === 'media-library') {
|
||||
return this.state.libraryResults && this.state.libraryMedia.length < this.state.libraryResults;
|
||||
}
|
||||
return super.canLoadMore;
|
||||
@@ -182,7 +181,10 @@ export class ImageSelector extends FileSelector {
|
||||
|
||||
async loadMore(...args) {
|
||||
await super.loadMore(...args);
|
||||
if (!this.props.useMediaLibrary) {
|
||||
if (!this.props.useMediaLibrary
|
||||
// The user can load more library media only when the filter is set.
|
||||
|| this.state.searchService !== 'media-library'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return this.keepLastLibraryMedia.add(this.fetchLibraryMedia(this.state.libraryMedia.length)).then(({ media }) => {
|
||||
|
||||
Reference in New Issue
Block a user