mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Hide wand if no extensions with menu button are active
This commit is contained in:
		| @@ -1,4 +1,4 @@ | |||||||
| import { callPopup, eventSource, event_types, extension_prompt_types, saveSettings, saveSettingsDebounced } from "../script.js"; | import { callPopup, eventSource, event_types, saveSettings, saveSettingsDebounced } from "../script.js"; | ||||||
| import { isSubsetOf, debounce } from "./utils.js"; | import { isSubsetOf, debounce } from "./utils.js"; | ||||||
| export { | export { | ||||||
|     getContext, |     getContext, | ||||||
| @@ -69,6 +69,20 @@ const getContext = () => window['SillyTavern'].getContext(); | |||||||
| const getApiUrl = () => extension_settings.apiUrl; | const getApiUrl = () => extension_settings.apiUrl; | ||||||
| let connectedToApi = false; | let connectedToApi = false; | ||||||
|  |  | ||||||
|  | function showHideExtensionsMenu() { | ||||||
|  |     const hasMenuItems = $('#extensionsMenu').children().length > 0; | ||||||
|  |  | ||||||
|  |     // We have menu items, so we can stop checking | ||||||
|  |     if (hasMenuItems) { | ||||||
|  |         clearInterval(menuInterval); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     $('#extensionsMenuButton').toggle(hasMenuItems); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Periodically check for new extensions | ||||||
|  | const menuInterval = setInterval(showHideExtensionsMenu, 1000); | ||||||
|  |  | ||||||
| async function doExtrasFetch(endpoint, args) { | async function doExtrasFetch(endpoint, args) { | ||||||
|     if (!args) { |     if (!args) { | ||||||
|         args = {} |         args = {} | ||||||
| @@ -219,7 +233,7 @@ function autoConnectInputHandler() { | |||||||
|  |  | ||||||
| function addExtensionsButtonAndMenu() { | function addExtensionsButtonAndMenu() { | ||||||
|     const buttonHTML = |     const buttonHTML = | ||||||
|         `<div id="extensionsMenuButton" class="fa-solid fa-magic-wand-sparkles" title="Extras Extensions" /></div>`; |         `<div id="extensionsMenuButton" style="display: none;" class="fa-solid fa-magic-wand-sparkles" title="Extras Extensions" /></div>`; | ||||||
|     const extensionsMenuHTML = `<div id="extensionsMenu" class="options-content" style="display: none;"></div>`; |     const extensionsMenuHTML = `<div id="extensionsMenu" class="options-content" style="display: none;"></div>`; | ||||||
|  |  | ||||||
|     $(document.body).append(extensionsMenuHTML); |     $(document.body).append(extensionsMenuHTML); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user