mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 10:59:53 +00:00
[refactor] Simplify current user resolved hook implementation (#5718)
## Summary Refactored `onUserResolved` function in auth composable to use VueUse `whenever` utility instead of manual watch implementation and use `immediate` option instead of invoking manually before creating watcher. ## Changes - **What**: Replaced manual watch + immediate check pattern with [VueUse whenever](https://vueuse.org/shared/whenever/) utility in `useCurrentUser.ts:37` ## Review Focus Behavioral equivalence verification - `whenever` with `immediate: true` should maintain identical callback timing and cleanup semantics. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5718-refactor-Simplify-current-user-resolved-hook-implementation-2766d73d365081008b6de156dd78f940) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { computed, watch } from 'vue'
|
||||
import { whenever } from '@vueuse/core'
|
||||
import { computed } from 'vue'
|
||||
|
||||
import { useFirebaseAuthActions } from '@/composables/auth/useFirebaseAuthActions'
|
||||
import { t } from '@/i18n'
|
||||
@@ -33,19 +34,8 @@ export const useCurrentUser = () => {
|
||||
return null
|
||||
})
|
||||
|
||||
const onUserResolved = (callback: (user: AuthUserInfo) => void) => {
|
||||
if (resolvedUserInfo.value) {
|
||||
callback(resolvedUserInfo.value)
|
||||
}
|
||||
|
||||
const stop = watch(resolvedUserInfo, (value) => {
|
||||
if (value) {
|
||||
callback(value)
|
||||
}
|
||||
})
|
||||
|
||||
return () => stop()
|
||||
}
|
||||
const onUserResolved = (callback: (user: AuthUserInfo) => void) =>
|
||||
whenever(resolvedUserInfo, callback, { immediate: true })
|
||||
|
||||
const userDisplayName = computed(() => {
|
||||
if (isApiKeyLogin.value) {
|
||||
|
||||
Reference in New Issue
Block a user