@@ -206,10 +206,14 @@ import {set, entries, createStore} from './thirdparty/idb-keyval.js';
206206 storageNodeConnector
207207 . execPeer ( "putItem" , { key, value : valueToStore } )
208208 . catch ( _reportPutItemError ) ;
209- // this is an in-memory tauri store that takes care of multi window case, since we have a single
210- // instance, all windows share this and can reconstruct the full view from the dumb file + this map
211- // when the editor boots up instead of having to write the dump file frequently.
212- window . __TAURI__ . invoke ( 'put_item' , { key, value : JSON . stringify ( valueToStore ) } ) ;
209+ // this is an in-memory tauri/electron store that takes care of multi window case, since we have a
210+ // single instance, all windows share this and can reconstruct the full view from the dump file + this
211+ // map when the editor boots up instead of having to write the dump file frequently.
212+ if ( window . __TAURI__ ) {
213+ window . __TAURI__ . invoke ( 'put_item' , { key, value : JSON . stringify ( valueToStore ) } ) ;
214+ } else if ( window . __ELECTRON__ ) {
215+ window . electronAPI . putItem ( key , JSON . stringify ( valueToStore ) ) ;
216+ }
213217 }
214218 if ( window . debugMode || isBrowser ) {
215219 // in debug mode, we write to browser storage in tauri and browser builds for eazy debug of storage.
@@ -291,13 +295,18 @@ import {set, entries, createStore} from './thirdparty/idb-keyval.js';
291295 return ;
292296 }
293297 if ( isDesktop ) {
294- async function mergeTauriInMemoryStorage ( ) {
295- // The tauri storeage is mainly used in multi window case, where if there are 2+ windows, each window
296- // is till live and has not commited the dump file to disc(they only do that on exit or 30 every secs).
298+ async function mergeNativeInMemoryStorage ( ) {
299+ // The native storage is mainly used in multi window case, where if there are 2+ windows, each window
300+ // is still live and has not committed the dump file to disc (they only do that on exit or every 30 secs).
297301 // so the dump file may be stale after window._tauriStorageRestorePromise in the case.
298- // we merge the local memory cache maintained at tauri rust side to address this.
302+ // we merge the local memory cache maintained at tauri/electron side to address this.
299303 try {
300- const map = await window . __TAURI__ . invoke ( 'get_all_items' ) || { } ;
304+ let map = { } ;
305+ if ( window . __TAURI__ ) {
306+ map = await window . __TAURI__ . invoke ( 'get_all_items' ) || { } ;
307+ } else if ( window . __ELECTRON__ ) {
308+ map = await window . electronAPI . getAllItems ( ) || { } ;
309+ }
301310 for ( const key of Object . keys ( map ) ) {
302311 cache [ key ] = JSON . parse ( map [ key ] ) ;
303312 }
@@ -317,7 +326,7 @@ import {set, entries, createStore} from './thirdparty/idb-keyval.js';
317326 }
318327 } )
319328 . catch ( console . error )
320- . finally ( mergeTauriInMemoryStorage ) ;
329+ . finally ( mergeNativeInMemoryStorage ) ;
321330 return ;
322331 }
323332 // Use browser default storage- IndexedDB
@@ -342,8 +351,10 @@ import {set, entries, createStore} from './thirdparty/idb-keyval.js';
342351 // do things to do that are critical to user experience here
343352 // We try to set window zoom as early as possible to prevent zoom flicker
344353 const zoomFactor = PhStore . getItem ( _PHSTORE_BOOT_DESKTOP_ZOOM_SCALE_KEY ) || 1 ;
345- if ( Phoenix . isNativeApp ) {
354+ if ( window . __TAURI__ ) {
346355 window . __TAURI__ . tauri . invoke ( "zoom_window" , { scaleFactor : zoomFactor } ) ;
356+ } else if ( window . __ELECTRON__ ) {
357+ window . electronAPI . zoomWindow ( zoomFactor ) ;
347358 }
348359 } ) ;
349360 /**
0 commit comments