(tabAtom: Atom<Tab>)
| 13 | const layoutModelMap: Map<string, LayoutModel> = new Map(); |
| 14 | |
| 15 | function getLayoutModelForTab(tabAtom: Atom<Tab>): LayoutModel { |
| 16 | const tabData = globalStore.get(tabAtom); |
| 17 | if (!tabData) return; |
| 18 | const tabId = tabData.oid; |
| 19 | if (layoutModelMap.has(tabId)) { |
| 20 | const layoutModel = layoutModelMap.get(tabData.oid); |
| 21 | if (layoutModel) { |
| 22 | return layoutModel; |
| 23 | } |
| 24 | } |
| 25 | const layoutModel = new LayoutModel(tabAtom, globalStore.get, globalStore.set); |
| 26 | |
| 27 | const staticTabId = globalStore.get(atoms.staticTabId); |
| 28 | if (tabId === staticTabId) { |
| 29 | const layoutStateAtom = getLayoutStateAtomFromTab(tabAtom, globalStore.get); |
| 30 | globalStore.sub(layoutStateAtom, () => { |
| 31 | layoutModel.onBackendUpdate(); |
| 32 | }); |
| 33 | } |
| 34 | |
| 35 | layoutModelMap.set(tabId, layoutModel); |
| 36 | return layoutModel; |
| 37 | } |
| 38 | |
| 39 | function getLayoutModelForTabById(tabId: string) { |
| 40 | const tabOref = WOS.makeORef("tab", tabId); |
no test coverage detected