| 
									
										
										
										
											2021-04-20 16:16:49 -07:00
										 |  |  | // Copyright 2021 Signal Messenger, LLC
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-06 14:59:34 -07:00
										 |  |  | import { MINUTE } from './durations'; | 
					
						
							| 
									
										
										
										
											2021-04-20 16:16:49 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | class PostLinkExperience { | 
					
						
							|  |  |  |   private hasNotFinishedSync: boolean; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   constructor() { | 
					
						
							|  |  |  |     this.hasNotFinishedSync = false; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   start() { | 
					
						
							|  |  |  |     this.hasNotFinishedSync = true; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // timeout "post link" after 10 minutes in case the syncs don't complete
 | 
					
						
							|  |  |  |     // in time or are never called.
 | 
					
						
							| 
									
										
										
										
											2021-10-06 14:59:34 -07:00
										 |  |  |     setTimeout(() => { | 
					
						
							| 
									
										
										
										
											2021-04-20 16:16:49 -07:00
										 |  |  |       this.stop(); | 
					
						
							| 
									
										
										
										
											2021-10-06 14:59:34 -07:00
										 |  |  |     }, 10 * MINUTE); | 
					
						
							| 
									
										
										
										
											2021-04-20 16:16:49 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   stop() { | 
					
						
							|  |  |  |     this.hasNotFinishedSync = false; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   isActive(): boolean { | 
					
						
							|  |  |  |     return this.hasNotFinishedSync === true; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const postLinkExperience = new PostLinkExperience(); |