forked from MapComplete/MapComplete
		
	Revert "Upload data less aggressively": mobile browsers don't ask for confirmation when closing
This reverts commit 0ef73c1c74.
			
			
This commit is contained in:
		
							parent
							
								
									0ef73c1c74
								
							
						
					
					
						commit
						d686a756fb
					
				
					 2 changed files with 33 additions and 1 deletions
				
			
		| 
						 | 
					@ -21,6 +21,38 @@ export default class PendingChangesUploader{
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        selectedFeature
 | 
				
			||||||
 | 
					            .stabilized(10000)
 | 
				
			||||||
 | 
					            .addCallback(feature => {
 | 
				
			||||||
 | 
					            if(feature === undefined){
 | 
				
			||||||
 | 
					                // The popup got closed - we flush
 | 
				
			||||||
 | 
					                changes.flushChanges("Flushing changes due to popup closed");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        document.addEventListener('mouseout', e => {
 | 
				
			||||||
 | 
					            // @ts-ignore
 | 
				
			||||||
 | 
					            if (!e.toElement && !e.relatedTarget) {
 | 
				
			||||||
 | 
					                changes.flushChanges("Flushing changes due to focus lost");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        document.onfocus = () => {
 | 
				
			||||||
 | 
					            changes.flushChanges("OnFocus")
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        document.onblur = () => {
 | 
				
			||||||
 | 
					            changes.flushChanges("OnFocus")
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        try{
 | 
				
			||||||
 | 
					            document.addEventListener("visibilitychange", () => {
 | 
				
			||||||
 | 
					                changes.flushChanges("Visibility change")
 | 
				
			||||||
 | 
					            }, false);
 | 
				
			||||||
 | 
					        }catch(e){
 | 
				
			||||||
 | 
					            console.warn("Could not register visibility change listener", e)
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        window.onbeforeunload = function(e){ 
 | 
					        window.onbeforeunload = function(e){ 
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if(changes.pending.data.length == 0){
 | 
					            if(changes.pending.data.length == 0){
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ export default class Constants {
 | 
				
			||||||
     * Used by 'PendingChangesUploader', which waits this amount of seconds to upload changes.
 | 
					     * Used by 'PendingChangesUploader', which waits this amount of seconds to upload changes.
 | 
				
			||||||
     * (Note that pendingChanges might upload sooner if the popup is closed or similar)
 | 
					     * (Note that pendingChanges might upload sooner if the popup is closed or similar)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    static updateTimeoutSec: number = 180;
 | 
					    static updateTimeoutSec: number = 30;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private static isRetina(): boolean {
 | 
					    private static isRetina(): boolean {
 | 
				
			||||||
        if (Utils.runningFromConsole) {
 | 
					        if (Utils.runningFromConsole) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue