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