MCPcopy Create free account
hub / github.com/chieapp/chie / getOrCreateWindow

Method getOrCreateWindow

src/model/window-store.ts:46–64  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

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) {

Callers 2

showWindowMethod · 0.95

Calls 2

saveWindowStateMethod · 0.95
restoreStateMethod · 0.45

Tested by

no test coverage detected