fix(web): refresh montage media list when returning to the tab
Media added to the shared library (or the project) after the montage was opened did not show up in the B-roll/sound/music picker until a page reload.
2847388 parent: 7d84a31 modified
web/src/project/steps/montage/useMontage.ts +8 -0 | @@ -134,6 +134,14 @@ export function useMontage(pid: string) { | ||
| 134 | 134 | } catch { /* la liste reste vide */ } |
| 135 | 135 | } |
| 136 | 136 | loadAvailable(); |
| 137 | + // un média versé dans la bibliothèque (ou le projet) depuis un autre onglet apparaît au retour sur le montage | |
| 138 | + const onVisible = () => { if (document.visibilityState === "visible") loadAvailable(); }; | |
| 139 | + document.addEventListener("visibilitychange", onVisible); | |
| 140 | + window.addEventListener("focus", loadAvailable); | |
| 141 | + onUnmounted(() => { | |
| 142 | + document.removeEventListener("visibilitychange", onVisible); | |
| 143 | + window.removeEventListener("focus", loadAvailable); | |
| 144 | + }); | |
| 137 | 145 | |
| 138 | 146 | return { view, tl, available, dirty, holding, busy, total, edit, shiftBeats, save, flush, undo, send, stop, exportResolve, load, loadAvailable }; |
| 139 | 147 | } |
| @@ -134,6 +134,14 @@ export function useMontage(pid: string) { | |||
| 134 | } catch { /* la liste reste vide */ } | 134 | } catch { /* la liste reste vide */ } |
| 135 | } | 135 | } |
| 136 | loadAvailable(); | 136 | loadAvailable(); |
| 137 | + // un média versé dans la bibliothèque (ou le projet) depuis un autre onglet apparaît au retour sur le montage | ||
| 138 | + const onVisible = () => { if (document.visibilityState === "visible") loadAvailable(); }; | ||
| 139 | + document.addEventListener("visibilitychange", onVisible); | ||
| 140 | + window.addEventListener("focus", loadAvailable); | ||
| 141 | + onUnmounted(() => { | ||
| 142 | + document.removeEventListener("visibilitychange", onVisible); | ||
| 143 | + window.removeEventListener("focus", loadAvailable); | ||
| 144 | + }); | ||
| 137 | 145 | ||
| 138 | return { view, tl, available, dirty, holding, busy, total, edit, shiftBeats, save, flush, undo, send, stop, exportResolve, load, loadAvailable }; | 146 | return { view, tl, available, dirty, holding, busy, total, edit, shiftBeats, save, flush, undo, send, stop, exportResolve, load, loadAvailable }; |
| 139 | } | 147 | } |