mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-10-31 22:28:08 +11:00 
			
		
		
		
	feat(menu): allow only one theme of each mode to be enabled at a time
This commit is contained in:
		
							parent
							
								
									7b6a244d72
								
							
						
					
					
						commit
						c3317bd9ec
					
				| @ -43,6 +43,21 @@ function List({ id, mods, description }) { | |||||||
|       const _get = () => isEnabled(mod.id), |       const _get = () => isEnabled(mod.id), | ||||||
|         _set = async (enabled) => { |         _set = async (enabled) => { | ||||||
|           await setEnabled(mod.id, enabled); |           await setEnabled(mod.id, enabled); | ||||||
|  |           // only one theme of each mode may be
 | ||||||
|  |           // enabled at a time ∴ disable others
 | ||||||
|  |           // on theme of same mode enabled
 | ||||||
|  |           if (enabled && id === "themes") { | ||||||
|  |             const isDark = mod.tags.includes("dark"), | ||||||
|  |               isLight = mod.tags.includes("light"); | ||||||
|  |             for (const other of mods) { | ||||||
|  |               if (other.id === mod.id) continue; | ||||||
|  |               const otherDark = other.tags.includes("dark"), | ||||||
|  |                 otherLight = other.tags.includes("light"); | ||||||
|  |               if ((isDark && otherDark) || (isLight && otherLight)) { | ||||||
|  |                 await setEnabled(other.id, false); | ||||||
|  |               } | ||||||
|  |             } | ||||||
|  |           } | ||||||
|           setState({ rerender: true, databaseUpdated: true }); |           setState({ rerender: true, databaseUpdated: true }); | ||||||
|         }; |         }; | ||||||
|       return html`<${Mod} ...${{ ...mod, _get, _set }} />`; |       return html`<${Mod} ...${{ ...mod, _get, _set }} />`; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user