Skip to content

Commit

Permalink
fix gallery view when preview is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmandic committed Jun 4, 2023
1 parent 63ca5c1 commit 9726b4d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def run_extension_installer(folder):
if not os.path.isfile(path_installer):
return
try:
log.debug(f"Running extension installer: {folder} / {path_installer}")
log.debug(f"Running extension installer: {path_installer}")
env = os.environ.copy()
env['PYTHONPATH'] = os.path.abspath(".")
result = subprocess.run(f'"{sys.executable}" "{path_installer}"', shell=True, env=env, check=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=folder)
Expand Down
35 changes: 20 additions & 15 deletions javascript/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,27 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres
const prevProgress = null;
const parentGallery = galleryEl ? galleryEl.parentNode : null;
let livePreview;
const img = new Image();
if (parentGallery) {
livePreview = document.createElement('div');
livePreview.className = 'livePreview';
parentGallery.insertBefore(livePreview, galleryEl);
const rect = galleryEl.getBoundingClientRect();
if (rect.width) {
livePreview.style.width = `${rect.width}px`;
livePreview.style.height = `${rect.height}px`;
let img;

const init = () => {
img = new Image();
if (parentGallery) {
livePreview = document.createElement('div');
livePreview.className = 'livePreview';
parentGallery.insertBefore(livePreview, galleryEl);
const rect = galleryEl.getBoundingClientRect();
if (rect.width) {
livePreview.style.width = `${rect.width}px`;
livePreview.style.height = `${rect.height}px`;
}
img.onload = function () {
livePreview.appendChild(img);
if (livePreview.childElementCount > 2) livePreview.removeChild(livePreview.firstElementChild);
};
}
img.onload = function () {
livePreview.appendChild(img);
if (livePreview.childElementCount > 2) livePreview.removeChild(livePreview.firstElementChild);
};
}

const done = function () {
const done = () => {
console.debug('task end: ', id_task);
localStorage.removeItem('task');
setProgress();
Expand All @@ -112,7 +116,7 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres
if (atEnd) atEnd();
};

const start = function (id_task, id_live_preview) {
const start = (id_task, id_live_preview) => {
request('./internal/progress', { id_task, id_live_preview }, (res) => {
lastState = res;
const elapsedFromStart = (new Date() - dateStart) / 1000;
Expand All @@ -122,6 +126,7 @@ function requestProgress(id_task, progressEl, galleryEl, atEnd = null, onProgres
return;
}
setProgress(res);
if (res.live_preview && !livePreview) init();
if (res.live_preview && galleryEl) img.src = res.live_preview;
if (onProgress) onProgress(res);
setTimeout(() => start(id_task, res.id_live_preview), opts.live_preview_refresh_period || 250);
Expand Down

0 comments on commit 9726b4d

Please sign in to comment.