| 
				(0128857)
			 | 
		 
		
			| 
				hgbot   
			 | 
		 
		
			| 
				2021-06-01 13:25   
							 | 
		 
		 
	 | 
	
		
		
			
				Repository: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2 [^] 
Changeset: 6a29db215e1e5701bf84c7239c36593816b12dd6 
Author: Gorka Gil <gorka.gil@openbravo.com> 
Date: 2021-06-01T12:16:15+02:00 
URL: https://gitlab.com/openbravo/product/pmods/org.openbravo.core2/-/commit/6a29db215e1e5701bf84c7239c36593816b12dd6 [^] 
 
Fix ISSUE-46831: delete the state on sources update in a better way 
 
Make use of the api to reset the state 
 
It is the more secure way to delete the state, removing a property of localstorage, 
after the reload, the ram is deleted so the state of the ram is lost. 
Then it will try to reload the state from disk, but before do that, will check if the 
localstorage property exists and if not, will delete the disk state db before try to 
load it. 
 
In this way we don't try to delete a running state and there is no race conditions that 
can cause problems. 
 
Other discarded options: 
 
a) With indexeddb api, delete the db of the state: 
  const persistenceDB = new OB.App.Class.IndexedDBController('state'); 
  persistenceDB.deleteDatabase().finally(() => { 
    window.location.reload(); 
  }); 
  - Problem: it deletes an db is use, gives an error that can not be deleted, 
  but in any case looks like working, but doesn't look to have the error, 
  also doesn't give security that will work always. Also doesn't ensure that 
  after delete and before the reload the db is saved again 
 
b) Purge db with localforage api: 
  OB.App.State.getPersistence().stateStorePersistor.purge() 
  It can be used since a recent change that ensures that state is started 
  before the check of sources. 
  - Problem: It works on F5, but not in logut/login not clear why. 
 
c) New state action that clear the state: 
  Tested but looks like is not working, not clear why but the state is not reset 
  maybe some protection in the code. 
  In any case will probably launch the listeners of the state, and since all the 
  spected variables are not there very probably will produce errors. 
 
--- 
M web-jspack/org.openbravo.core2/src/registerServiceWorker.js 
--- 
			 | 
		 
		 
	 |