mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-31 13:29:55 +00:00
Adds watch on auth state that refreshes remote config. In future PR, the remote config system and feature flags should be consolidated and moved out of ComfyApi. Currently, we need feature flags before GraphView mounts, but also need to add auth headers after auth, which necessitates these parallel systems temporarily ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7197-refresh-feature-flags-on-auth-or-subscription-state-change-2c06d73d3650810a906ad36a60c86600) by [Unito](https://www.unito.io)
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { watchDebounced } from '@vueuse/core'
|
|
|
|
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
|
import { useSubscription } from '@/platform/cloud/subscription/composables/useSubscription'
|
|
import { loadRemoteConfig } from '@/platform/remoteConfig/remoteConfig'
|
|
import { refreshRemoteConfig } from '@/platform/remoteConfig/refreshRemoteConfig'
|
|
import { useExtensionService } from '@/services/extensionService'
|
|
|
|
/**
|
|
* Cloud-only extension that polls for remote config updates
|
|
* Initial config load happens in main.ts before any other imports
|
|
*/
|
|
useExtensionService().registerExtension({
|
|
name: 'Comfy.Cloud.RemoteConfig',
|
|
|
|
setup: async () => {
|
|
const { isLoggedIn } = useCurrentUser()
|
|
const { isActiveSubscription } = useSubscription()
|
|
|
|
watchDebounced(
|
|
[isLoggedIn, isActiveSubscription],
|
|
() => {
|
|
if (!isLoggedIn.value) return
|
|
void refreshRemoteConfig()
|
|
},
|
|
{ debounce: 256, immediate: true }
|
|
)
|
|
|
|
// Poll for config updates every 10 minutes
|
|
setInterval(() => void loadRemoteConfig(), 600_000)
|
|
}
|
|
})
|