(blockId: string, key: T)
| 175 | const settingsAtomCache = new Map<string, Atom<any>>(); |
| 176 | |
| 177 | function getOverrideConfigAtom<T extends keyof SettingsType>(blockId: string, key: T): Atom<SettingsType[T]> { |
| 178 | if (isPreviewWindow()) return NullAtom as Atom<SettingsType[T]>; |
| 179 | const blockCache = getSingleBlockAtomCache(blockId); |
| 180 | const overrideAtomName = "#settingsoverride-" + key; |
| 181 | let overrideAtom = blockCache.get(overrideAtomName); |
| 182 | if (overrideAtom != null) { |
| 183 | return overrideAtom; |
| 184 | } |
| 185 | overrideAtom = atom((get) => { |
| 186 | const blockMetaKeyAtom = getBlockMetaKeyAtom(blockId, key as any); |
| 187 | const metaKeyVal = get(blockMetaKeyAtom); |
| 188 | if (metaKeyVal != null) { |
| 189 | return metaKeyVal; |
| 190 | } |
| 191 | const connNameAtom = getBlockMetaKeyAtom(blockId, "connection"); |
| 192 | const connName = get(connNameAtom); |
| 193 | const connConfigKeyAtom = getConnConfigKeyAtom(connName, key as any); |
| 194 | const connConfigKeyVal = get(connConfigKeyAtom); |
| 195 | if (connConfigKeyVal != null) { |
| 196 | return connConfigKeyVal; |
| 197 | } |
| 198 | const settingsKeyAtom = getSettingsKeyAtom(key); |
| 199 | const settingsVal = get(settingsKeyAtom); |
| 200 | if (settingsVal != null) { |
| 201 | return settingsVal; |
| 202 | } |
| 203 | return null; |
| 204 | }); |
| 205 | blockCache.set(overrideAtomName, overrideAtom); |
| 206 | return overrideAtom; |
| 207 | } |
| 208 | |
| 209 | function useOverrideConfigAtom<T extends keyof SettingsType>(blockId: string | null, key: T): SettingsType[T] { |
| 210 | if (blockId == null) { |
no test coverage detected