mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 09:56:44 +00:00 
			
		
		
		
	keep videos infos in localStorage after clear it
This commit is contained in:
		
							parent
							
								
									73928e1af5
								
							
						
					
					
						commit
						e8f7616c56
					
				| @ -40,7 +40,6 @@ export class Onboarding extends React.Component { | ||||
| 
 | ||||
|   componentWillUnmount() { | ||||
|     this.props.removeVideos(); | ||||
|     localStorage.removeItem('videos'); | ||||
|   } | ||||
| 
 | ||||
|   setVideoEnd = () => { | ||||
| @ -84,6 +83,7 @@ export class Onboarding extends React.Component { | ||||
|   }; | ||||
| 
 | ||||
|   updateLocalStorage = (index, current, duration) => { | ||||
| 
 | ||||
|     // Update store
 | ||||
|     this.props.updateVideoStartTime(index, current); | ||||
| 
 | ||||
| @ -91,10 +91,11 @@ export class Onboarding extends React.Component { | ||||
|     let videosTime = JSON.parse(localStorage.getItem('videos')); | ||||
|     videosTime[index].startTime = current; | ||||
|     let percent = current * 100 / duration; | ||||
|     const video = videosTime.find((element) => element.order === index); | ||||
| 
 | ||||
|     if (percent >= 80) { | ||||
|       if (videosTime[index].end === false) { | ||||
|         videosTime[index].end = true; | ||||
|       if (video.end === false) { | ||||
|         video.end = true; | ||||
|         this.props.setVideoEnd(index, true); | ||||
|       } | ||||
|     } | ||||
| @ -107,7 +108,7 @@ export class Onboarding extends React.Component { | ||||
|   // eslint-disable-line jsx-handler-names
 | ||||
|   render() { | ||||
|     const { videos, onClick, setVideoDuration } = this.props; | ||||
| 
 | ||||
|     console.log(videos); | ||||
|     return ( | ||||
|       <div className={cn(styles.videosWrapper, videos.length > 0 ? styles.visible : styles.hidden)}> | ||||
|         <div className={cn(styles.videosContent, this.state.showVideos ? styles.shown : styles.hide)}> | ||||
|  | ||||
| @ -11,7 +11,6 @@ function* getVideos() { | ||||
|       headers: { | ||||
|         'Content-Type': 'application/json', | ||||
|       }, | ||||
|       mode: 'no-cors', | ||||
|     }, | ||||
|     false, | ||||
|     true, | ||||
| @ -24,6 +23,7 @@ function* getVideos() { | ||||
|         end: false, | ||||
|         key: i, | ||||
|         id: videos[i].id, | ||||
|         order: videos[i].order, | ||||
|       }; | ||||
|     }); | ||||
|      | ||||
| @ -36,6 +36,7 @@ function* getVideos() { | ||||
| 
 | ||||
|     yield put( | ||||
|       getVideosSucceeded( | ||||
| 
 | ||||
|         videos.map((video, index) => { | ||||
|           video.isOpen = false; | ||||
|           video.duration = null; | ||||
|  | ||||
| @ -21,7 +21,14 @@ const auth = { | ||||
| 
 | ||||
|   clearAppStorage() { | ||||
|     if (localStorage) { | ||||
|        | ||||
|       const videos = auth.get('videos'); | ||||
|       const onboarding = auth.get('onboarding'); | ||||
|       localStorage.clear(); | ||||
|       if (videos !== null) { | ||||
|         localStorage.setItem('videos', JSON.stringify(videos)); | ||||
|       } | ||||
|       localStorage.setItem('onboarding', onboarding); | ||||
|     } | ||||
| 
 | ||||
|     if (sessionStorage) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ky
						Ky