(id: string)
| 44 | // Get or create window with |id|. The window is created lazily and will |
| 45 | // be destroyed when closed. |
| 46 | getOrCreateWindow(id: string) { |
| 47 | let win = this.#windows[id]; |
| 48 | if (!win) { |
| 49 | win = this.#windows[id] = this.#windowCreator(id); |
| 50 | if (id in this.#windowStates) { |
| 51 | win.restoreState(this.#windowStates[id]); |
| 52 | } else { |
| 53 | win.restoreState({}); |
| 54 | win.window.center(); |
| 55 | } |
| 56 | win.window.onClose = () => { |
| 57 | this.saveWindowState(id); |
| 58 | // It is possible to cache, but windows are cheap to create in "gui" so |
| 59 | // we just recreate the window every time. |
| 60 | delete this.#windows[id]; |
| 61 | }; |
| 62 | } |
| 63 | return win; |
| 64 | } |
| 65 | |
| 66 | // Call getWindow and show, it is used most commonly so add a method for it. |
| 67 | showWindow(id: string) { |
no test coverage detected