1
1
import { type PlayerRef } from '@remotion/player' ;
2
- import { useNavigate } from 'react-router-dom' ;
3
2
4
3
import {
5
4
Box ,
@@ -21,6 +20,8 @@ import {
21
20
useAppSelector ,
22
21
useCallback ,
23
22
useEffect ,
23
+ useLocation ,
24
+ useNavigate ,
24
25
useRef ,
25
26
} from '~/bundles/common/hooks/hooks.js' ;
26
27
import { IconName } from '~/bundles/common/icons/icons.js' ;
@@ -42,16 +43,29 @@ import {
42
43
} from '../constants/constants.js' ;
43
44
import { NotificationMessage , NotificationTitle } from '../enums/enums.js' ;
44
45
import { getVoicesConfigs } from '../helpers/helpers.js' ;
46
+ import { selectVideoDataById } from '../store/selectors.js' ;
45
47
import { actions as studioActions } from '../store/studio.js' ;
46
48
47
49
const Studio : React . FC = ( ) => {
50
+ const { state : locationState } = useLocation ( ) ;
51
+
52
+ const videoData = useAppSelector ( ( state ) =>
53
+ selectVideoDataById ( state , locationState ?. id ) ,
54
+ ) ;
55
+
48
56
const { scenes, scripts, videoName, videoId, scriptPlayer } =
49
57
useAppSelector ( ( { studio } ) => studio ) ;
50
58
51
59
const playerReference = useRef < PlayerRef > ( null ) ;
52
60
const dispatch = useAppDispatch ( ) ;
53
61
const navigate = useNavigate ( ) ;
54
62
63
+ useEffect ( ( ) : void => {
64
+ if ( videoData ) {
65
+ void dispatch ( studioActions . loadVideoData ( videoData ) ) ;
66
+ }
67
+ } , [ dispatch , videoData ] ) ;
68
+
55
69
const handleResize = useCallback ( ( ) => {
56
70
dispatch ( studioActions . changeVideoSize ( ) ) ;
57
71
} , [ dispatch ] ) ;
@@ -98,7 +112,9 @@ const Studio: React.FC = () => {
98
112
} , [ dispatch , navigate , scenes , scripts , videoId , videoName ] ) ;
99
113
100
114
useEffect ( ( ) => {
101
- return ( ) => void dispatch ( studioActions . resetStudio ( ) ) ;
115
+ return ( ) => {
116
+ dispatch ( studioActions . resetStudio ( ) ) ;
117
+ } ;
102
118
} , [ dispatch ] ) ;
103
119
104
120
const handleSaveDraft = useCallback ( ( ) : void => {
0 commit comments