mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-29 14:47:40 +00:00 
			
		
		
		
	DynaView: Suppress local storage errors
This commit is contained in:
		| @@ -31,6 +31,8 @@ var LOCAL_STORAGE_KEY_PREFIX = "tw5-dynaview-scroll-position#"; | |||||||
|  |  | ||||||
| var hasRestoredScrollPosition = false; | var hasRestoredScrollPosition = false; | ||||||
|  |  | ||||||
|  | var localStorageHasFailed = false; | ||||||
|  |  | ||||||
| exports.startup = function() { | exports.startup = function() { | ||||||
| 	var topmost = null, lastScrollY; | 	var topmost = null, lastScrollY; | ||||||
| 	$tw.boot.disableStartupNavigation = true; | 	$tw.boot.disableStartupNavigation = true; | ||||||
| @@ -165,6 +167,7 @@ function updateAddressBar() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function saveScrollPosition() { | function saveScrollPosition() { | ||||||
|  | 	if(!localStorageHasFailed) { | ||||||
| 		if(hasRestoredScrollPosition && $tw.wiki.getTiddlerText("$:/config/DynaView/RestoreScrollPositionAtStartup") === "yes") { | 		if(hasRestoredScrollPosition && $tw.wiki.getTiddlerText("$:/config/DynaView/RestoreScrollPositionAtStartup") === "yes") { | ||||||
| 			var top = findTopmostTiddler(); | 			var top = findTopmostTiddler(); | ||||||
| 			if(top.element) { | 			if(top.element) { | ||||||
| @@ -174,7 +177,8 @@ function saveScrollPosition() { | |||||||
| 						offset: top.offset | 						offset: top.offset | ||||||
| 					})); | 					})); | ||||||
| 				} catch(e) { | 				} catch(e) { | ||||||
| 				console.log("Error setting local storage",e) | 					localStorageHasFailed = true; | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -182,11 +186,13 @@ function saveScrollPosition() { | |||||||
|  |  | ||||||
| function restoreScrollPosition() { | function restoreScrollPosition() { | ||||||
| 	var json; | 	var json; | ||||||
|  | 	if(!localStorageHasFailed) { | ||||||
| 		try { | 		try { | ||||||
| 			json = JSON.parse(window.localStorage.getItem(LOCAL_STORAGE_KEY_PREFIX + window.location.pathname)); | 			json = JSON.parse(window.localStorage.getItem(LOCAL_STORAGE_KEY_PREFIX + window.location.pathname)); | ||||||
| 		} catch(e) { | 		} catch(e) { | ||||||
| 		// Ignore errors | 			localStorageHasFailed = true; | ||||||
| 		};		 | 		};		 | ||||||
|  | 	} | ||||||
| 	return json; | 	return json; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston