Skip to content
Snippets Groups Projects
Commit 24177b5e authored by Romain Derie's avatar Romain Derie
Browse files

[FIX] web_editor: avoid fetching optimized images which can't be shown


Before this commit, when opening the media dialog, the optimized images
would be fetched too.
An optimized image is an image related to an original one which received
some modification (crop etc).
Those optimized images are hidden by default, and can only be shown when
toggling the "Show optimized" option, which can be shown only in debug
mode.

So, fetching those images outside debug mode is:
1. Useless, as we don't do anything with those and never show them
2. Buggy sometimes, as a full patch of "Load more" images could be
   composed of only optimized images, meaning the "load more" will
   actually look like it did nothing, as all received images are (and
   will remain) hidden.

There is a tiny exception: if the edited image is an optimized one, we
still need to fetch it's attachment so we can show this image in the
media dialog as selected.

This fix thus filter out all the optimized images (except the one from
the explained exception) from the `search_read()`.

opw-3372811

closes odoo/odoo#127799

X-original-commit: 74a79ce6
Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: default avatarRomain Derie (rde) <rde@odoo.com>
parent 62cc16da
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,31 @@ export class ImageSelector extends FileSelector {
}
domain.push('!', ['name', '=like', '%.crop']);
domain.push('|', ['type', '=', 'binary'], '!', ['url', '=like', '/%/static/%']);
// Optimized images (meaning they are related to an `original_id`) can
// only be shown in debug mode as the toggler to make those images
// appear is hidden when not in debug mode.
// There is thus no point to fetch those optimized images outside debug
// mode. Worst, it leads to bugs: it might fetch only optimized images
// when clicking on "load more" which will look like it's bugged as no
// images will appear on screen (they all will be hidden).
if (!this.env.debug) {
const subDomain = [false];
// Particular exception: if the edited image is an optimized
// image, we need to fetch it too so it's displayed as the
// selected image when opening the media dialog.
// We might get a few more optimized image than necessary if the
// original image has multiple optimized images but it's not a
// big deal.
const originalId = this.props.media && this.props.media.dataset.originalId;
if (originalId) {
subDomain.push(originalId);
}
domain.push(['original_id', 'in', subDomain]);
}
return domain;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment