mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	Various fixes
This commit is contained in:
		| @@ -5,14 +5,18 @@ import Get from '../api/preferences/index.js'; | ||||
| class Basic { | ||||
|     viewRange = '1M'; | ||||
|     darkMode = 'browser'; | ||||
|     listPageSize = 10; | ||||
|     locale = 'en-US'; | ||||
|     language = 'en-US'; | ||||
|     locale = 'en-US'; | ||||
|  | ||||
|     // others, to be used in the future. | ||||
|     listPageSize = 10; | ||||
|     currencyCode = 'AAA'; | ||||
|     currencyId = '0'; | ||||
|     ready = false; | ||||
|     count = 0; | ||||
|     readyCount = 4; | ||||
|     start = null; | ||||
|     end = null; | ||||
|  | ||||
|     constructor() { | ||||
|     } | ||||
| @@ -27,11 +31,25 @@ class Basic { | ||||
|     loadVariable(name) { | ||||
|         if (window.hasOwnProperty(name)) { | ||||
|             this[name] = window[name]; | ||||
|             this.count++; | ||||
|             if (this.count === this.readyCount) { | ||||
|                 // trigger event: | ||||
|                 const event = new Event("BasicStoreReady"); | ||||
|                 document.dispatchEvent(event); | ||||
|             } | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|         // load from local storage | ||||
|         if (window.Alpine.store(name)) { | ||||
|             this[name] = window.Alpine.store(name); | ||||
|         if (localStorage.getItem(name)) { | ||||
|             this[name] = localStorage.getItem(name); | ||||
|             this.count++; | ||||
|             if (this.count === this.readyCount) { | ||||
|                 // trigger event: | ||||
|                 const event = new Event("BasicStoreReady"); | ||||
|                 document.dispatchEvent(event); | ||||
|             } | ||||
|  | ||||
|             return; | ||||
|         } | ||||
|         // grab | ||||
| @@ -43,12 +61,26 @@ class Basic { | ||||
|         this.count++; | ||||
|         let value = response.data.data.attributes.data; | ||||
|         this[name] = value; | ||||
|         localStorage.setItem(name, value); | ||||
|         if (this.count === this.readyCount) { | ||||
|             // trigger event: | ||||
|             const event = new Event("BasicStoreReady"); | ||||
|             document.dispatchEvent(event); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     store(name, value) { | ||||
|         this[name] = value; | ||||
|         localStorage.setItem(name, value); | ||||
|     } | ||||
|  | ||||
|     getFromLocalStorage(name) { | ||||
|         return localStorage.getItem(name); | ||||
|     } | ||||
|  | ||||
|     isReady() { | ||||
|         return this.count === this.readyCount; | ||||
|     } | ||||
| } | ||||
|  | ||||
| export default Basic; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user