(blockId: string, key: T)
| 117 | } |
| 118 | |
| 119 | function getBlockMetaKeyAtom<T extends keyof MetaType>(blockId: string, key: T): Atom<MetaType[T]> { |
| 120 | const blockCache = getSingleBlockAtomCache(blockId); |
| 121 | const metaAtomName = "#meta-" + key; |
| 122 | let metaAtom = blockCache.get(metaAtomName); |
| 123 | if (metaAtom != null) { |
| 124 | return metaAtom; |
| 125 | } |
| 126 | metaAtom = atom((get) => { |
| 127 | const blockAtom = WOS.getWaveObjectAtom(WOS.makeORef("block", blockId)); |
| 128 | const blockData = get(blockAtom); |
| 129 | return blockData?.meta?.[key]; |
| 130 | }); |
| 131 | blockCache.set(metaAtomName, metaAtom); |
| 132 | return metaAtom; |
| 133 | } |
| 134 | |
| 135 | function getTabMetaKeyAtom<T extends keyof MetaType>(tabId: string, key: T): Atom<MetaType[T]> { |
| 136 | return getOrefMetaKeyAtom(WOS.makeORef("tab", tabId), key); |
no test coverage detected