Skip to content

Commit 4b87261

Browse files
committed
Revert UI video handling
1 parent 3341a6c commit 4b87261

5 files changed

Lines changed: 63 additions & 101 deletions

File tree

‎new-ui/biome.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"root": true,
3-
"$schema": "https://biomejs.dev/schemas/2.5.13/schema.json",
3+
"$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
44
"vcs": {
55
"enabled": false,
66
"clientKind": "git",

‎new-ui/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"preview": "vite preview"
1515
},
1616
"dependencies": {
17-
"@biomejs/biome": "2.5.13",
17+
"@biomejs/biome": "2.5.14",
1818
"@floating-ui/react": "^0.27.20",
1919
"@stablelib/base64": "^2.0.1",
2020
"@stablelib/x25519": "^2.0.1",
@@ -36,7 +36,7 @@
3636
"dayjs": "^1.11.23",
3737
"motion": "^12.43.0",
3838
"p-timeout": "^7.0.2",
39-
"prettier": "^3.9.6",
39+
"prettier": "^3.9.7",
4040
"qrcode.react": "^4.2.0",
4141
"radashi": "^12.9.4",
4242
"react": "^19.3.0",

‎new-ui/pnpm-lock.yaml‎

Lines changed: 51 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎new-ui/src/pages/welcome/components/SlideVideo.tsx‎

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { useEffect, useRef, useState } from 'react';
2-
import { isPresent } from '../../../shared/utils/isPresent';
1+
import { useQuery } from '@tanstack/react-query';
32

43
type Props = {
54
src: string;
@@ -10,61 +9,21 @@ export const SlideVideo = ({ src, poster }: Props) => {
109
// Bundled assets are served without range request support, which makes video
1110
// playback stutter. Play it from an in-memory blob instead.
1211
// https://github.com/orgs/tauri-apps/discussions/7870
13-
const [blobSrc, setBlobSrc] = useState<string>();
14-
const videoRef = useRef<HTMLVideoElement>(null);
15-
16-
useEffect(() => {
17-
let objectUrl: string | undefined;
18-
let cancelled = false;
19-
20-
void (async () => {
12+
const { data: blobSrc } = useQuery({
13+
queryKey: ['slide-video', src] as const,
14+
queryFn: async () => {
2115
const response = await fetch(src);
22-
const blob = await response.blob();
23-
if (cancelled) return;
24-
objectUrl = URL.createObjectURL(blob);
25-
setBlobSrc(objectUrl);
26-
})();
27-
28-
return () => {
29-
cancelled = true;
30-
if (isPresent(objectUrl)) {
31-
URL.revokeObjectURL(objectUrl);
32-
}
33-
};
34-
}, [src]);
35-
36-
// The welcome window is pre-built hidden and only hidden again on close, so the webview
37-
// outlives the window being on screen.
38-
useEffect(() => {
39-
const video = videoRef.current;
40-
if (!isPresent(video) || !isPresent(blobSrc)) return;
41-
42-
const syncPlayback = () => {
43-
if (document.visibilityState === 'visible') {
44-
void video.play().catch(() => {
45-
// Autoplay can be refused while the window is not interactable yet.
46-
});
47-
} else {
48-
video.pause();
49-
}
50-
};
51-
52-
syncPlayback();
53-
document.addEventListener('visibilitychange', syncPlayback);
54-
55-
return () => {
56-
document.removeEventListener('visibilitychange', syncPlayback);
57-
video.pause();
58-
};
59-
}, [blobSrc]);
16+
return URL.createObjectURL(await response.blob());
17+
},
18+
});
6019

6120
return (
6221
<video
63-
ref={videoRef}
6422
src={blobSrc}
6523
poster={poster}
6624
width={'100%'}
6725
height={'auto'}
26+
autoPlay
6827
loop
6928
muted
7029
playsInline

‎src-tauri/Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ defguard_wireguard_rs = { workspace = true, features = ["check_dependencies"] }
100100
dirs-next.workspace = true
101101
hyper-util = "0.1"
102102
log.workspace = true
103-
os_info = { version = "3.14", default-features = false }
103+
os_info = { version = "3.15", default-features = false }
104104
prost.workspace = true
105105
regex = "1.12"
106106
reqwest.workspace = true

0 commit comments

Comments
 (0)