Open ari62 opened 3 years ago
Do you need this second window to be loaded with the file scheme or could it be done with the capacitor-electron
scheme?
If the latter is true, sounds like I need to add a CreateWindow
type method for people to use.
I don't have a preference for the scheme, I was just pointing out that one window uses one file and another uses capacitor-electron.
Not sure if a new method is needed. I think using "partition" or "session" in the webPreferences section should work to share session info, but it doesn't seem to when the config is passed to createCapacitorElectronApp .
Describe the bug I haven't been able to figure out how to share the data in the various storage mechanisms between the main window and new browser windows I create from clicking on tray menu options. I have tried using "parent", "session" and "partition" on the BrowserWindow Objects I create. For example:
Where mySession is an object set as the session object in the main window's config or retrieved through
this.mainWindow.webContents.session
. Neither way seemed to help. Usingpartition: 'persist:myapp',
gives this error, but because setting session doesn't help I don't think that would help anyway:(node:74976) UnhandledPromiseRejectionWarning: Error: ERR_FAILED (-2) loading 'capacitor-electron://-' at rejectAndCleanup (electron/js2c/browser_init.js:205:1493) at Object.stopLoadingListener (electron/js2c/browser_init.js:205:1868) at Object.emit (events.js:315:20) (node:74976) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag
--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:74976) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
To Reproduce Steps to reproduce the behavior:
Create an electron-capacitor app and main window:
I tried making the Tray through the above config as well as making the tray object separately.
Create another window as above "trayWindow" is created and load a url :
const loadPromise: Promise<void> = trayWindow.loadURL(trayUrl);
Expected behavior The main window's local storage, session storage and indexedDb storage is shared with other windows created in the app.
Screenshots Notice the main window uses the
capacitor-electron://
schema in the following screenshot:However the other browser windows created use the
file://
schema:The IndexedDb is different regardless.
Desktop (please complete the following information):
Additional context I am not writing to IndexedDb directly, but am rather using AngularFire and AngularFireAuth in the renderer process, so I can't grab the data in the main process and pass it to the various windows without significant alterations. I don't want to login again in a new browser window when I open a window from the tray if I have already logged in to the main window. The login info is stored in IndexedDB, as show in the screenshots. This seems to be related to this stackoverflow question : sharing indexdDb
However because of the different schemas ("capacitor-electron://" vs "file://" )in my use case I am posting it here as well.