mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
- Add user_created field to all item update operations to maintain proper user association - Update useMyProfile hook to use direct computation instead of useMemo to avoid React hook queue issues - Refactor UserControl to use useMyProfile hook for consistency - Fix user_created handling in LocateControl, ItemFormPopup, useSelectPosition, and itemFunctions - Add user parameter to linkItem, unlinkItem, and related functions with proper TypeScript signatures - Update all function calls and tests to include user parameter - Ensure proper null safety with user ?? undefined pattern 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
588 B
TypeScript
20 lines
588 B
TypeScript
import { useAuth } from '#components/Auth/useAuth'
|
|
|
|
import { useItems, useAllItemsLoaded } from './useItems'
|
|
|
|
export const useMyProfile = () => {
|
|
const items = useItems()
|
|
const allItemsLoaded = useAllItemsLoaded()
|
|
const { user } = useAuth()
|
|
|
|
// Find the user's profile item
|
|
const myProfile = items.find(
|
|
(item) => item.layer?.userProfileLayer && item.user_created?.id === user?.id,
|
|
)
|
|
|
|
// allItemsLoaded is not reliable, so we check if items.length > 0
|
|
const isMyProfileLoaded = allItemsLoaded && items.length > 0 && !!user
|
|
|
|
return { myProfile, isMyProfileLoaded }
|
|
}
|