Skip to content

Commit a1820be

Browse files
authored
fix ios preview (#1302)
* Revert "Ensure live preview is not cached" This reverts commit 80faa47. * fix ios cache busting on preview fix * rename cache busting function, remove leftover url()´s * fix for manual page sidebar Undefined variable $appVersion * fix ci --------- Co-authored-by: Andreas Skomski
1 parent d661523 commit a1820be

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

assets/js/preview.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* eslint n/no-unsupported-features/node-builtins: "off" */
2+
23
/* globals photoBooth photoboothTools */
34

4-
function addCacheBustingParam(url) {
5+
function getPreviewUrlWithCacheBusting() {
6+
const url = getBasePreviewUrl();
57
const timestamp = new Date().getTime();
68

79
if (url.includes('?')) {
@@ -11,10 +13,16 @@ function addCacheBustingParam(url) {
1113
return `${url}?t=${timestamp}`;
1214
}
1315

14-
function getRootProperty(property) {
15-
const root = document.documentElement;
16-
const style = getComputedStyle(root);
17-
return style.getPropertyValue(property).trim();
16+
function getBasePreviewUrl() {
17+
if (!config.preview || !config.preview.url) {
18+
return '';
19+
}
20+
21+
const raw = config.preview.url;
22+
//remove url("") if present
23+
const match = raw.match(/^url\((['"]?)(.+?)\1\)$/);
24+
25+
return match ? match[2] : raw;
1826
}
1927

2028
const photoboothPreview = (function () {
@@ -196,8 +204,9 @@ const photoboothPreview = (function () {
196204
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
197205
photoboothTools.console.logDev('Preview: Preview at countdown from URL.');
198206
setTimeout(function () {
199-
url.attr('src', addCacheBustingParam(getRootProperty('--background-preview')));
207+
url.css('background-image', 'url("' + getPreviewUrlWithCacheBusting() + '")');
200208
url.show();
209+
url.addClass('streaming');
201210
}, config.preview.url_delay);
202211
}
203212
break;
@@ -208,8 +217,9 @@ const photoboothPreview = (function () {
208217
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
209218
photoboothTools.console.logDev('Preview: Preview from URL.');
210219
setTimeout(function () {
211-
url.attr('src', addCacheBustingParam(getRootProperty('--background-preview')));
220+
url.css('background-image', 'url("' + getPreviewUrlWithCacheBusting() + '")');
212221
url.show();
222+
url.addClass('streaming');
213223
}, config.preview.url_delay);
214224
}
215225
break;
@@ -235,8 +245,9 @@ const photoboothPreview = (function () {
235245
tracks.forEach((track) => track.stop());
236246
api.stream = null;
237247
}
248+
url.removeClass('streaming');
238249
url.hide();
239-
url.attr('src', '');
250+
url.css('background-image', 'none');
240251
video.hide();
241252
pictureFrame.hide();
242253
collageFrame.hide();

assets/js/test-preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const photoboothPreviewTest = (function () {
9696
if (config.preview.mode === PreviewMode.DEVICE.valueOf()) {
9797
photoboothPreview.stopVideo();
9898
} else if (config.preview.mode === PreviewMode.URL.valueOf()) {
99-
previewIpcam.attr('src', '');
99+
previewIpcam.removeClass('streaming');
100100
previewIpcam.hide();
101101
}
102102

assets/sass/components/_preview.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,9 @@
9292
scale: 1 -1;
9393
}
9494
}
95+
96+
#preview--ipcam {
97+
&.streaming {
98+
background-image: var(--background-preview);
99+
}
100+
}

manual/index.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@
1919
$configsetup = require PathUtility::getAbsolutePath('lib/configsetup.inc.php');
2020

2121
$languageService = LanguageService::getInstance();
22-
$pageTitle = 'Manual - ' . ApplicationService::getInstance()->getTitle();
22+
23+
$appName = ApplicationService::getInstance()->getTitle();
24+
$appVersion = ApplicationService::getInstance()->getVersion();
25+
$page = 'Manual';
26+
$pageTitle = $page . ' - ' . $appName . ' (' . $appVersion . ')';
27+
2328
include PathUtility::getAbsolutePath('admin/components/head.admin.php');
2429
include PathUtility::getAbsolutePath('admin/helper/index.php');
2530

@@ -31,7 +36,7 @@
3136
<!-- body -->
3237
<div class="w-full h-full flex flex-1 flex-col md:flex-row mt-5 overflow-hidden">
3338
<?php
34-
$sidebarHeadline = 'Manual';
39+
$sidebarHeadline = $page . ' - ' . $appName;
3540
include PathUtility::getAbsolutePath('admin/components/sidebar.php');
3641
?>
3742
<div class="flex flex-1 flex-col bg-content-1 rounded-xl ml-5 mr-5 mb-5 md:ml-0 overflow-hidden">

src/Service/ConfigurationService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ protected function processMigration(array $config): array
213213
$config['preview']['mode'] = 'device_cam';
214214
}
215215

216-
// Migrate Preview URL
216+
// Migrate Preview URL, remove surrounding url("...")
217217
if (isset($config['preview']['url']) && substr($config['preview']['url'], 0, 4) === 'url(' && substr($config['preview']['url'], -1) === ')') {
218218
$config['preview']['url'] = trim(substr($config['preview']['url'], 4, -1), '"\'');
219219
}

template/components/preview.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
echo '<div id="preview-container" style="aspect-ratio: ' . $comp . '">';
4646
echo '<div id="preview-wrapper" style="aspect-ratio:' . $comp . '">';
4747
echo '<video id="preview--video" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '" autoplay playsinline></video>';
48-
echo '<img id="preview--ipcam" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '"></img>';
48+
echo '<div id="preview--ipcam" style="' . $composed_style . '" class="' . $previewFlipClass . ' ' . $previewStyleClass . '"></div>';
4949
echo '<div id="preview--none">' . $languageService->translate('no_preview') . '</div>';
5050
echo '</div></div>';
5151

0 commit comments

Comments
 (0)