diff --git a/editor/src/core/shared/multiplayer-hooks.tsx b/editor/src/core/shared/multiplayer-hooks.tsx index 6831e3a8ee3a..453398278fe1 100644 --- a/editor/src/core/shared/multiplayer-hooks.tsx +++ b/editor/src/core/shared/multiplayer-hooks.tsx @@ -6,6 +6,8 @@ import { } from '../../components/canvas/remix/utopia-remix-root-component' import type { RemixPresence } from './multiplayer' import * as EP from './element-path' +import { Substores, useEditorState } from '../../components/editor/store/store-hook' +import { isLoggedIn } from '../../common/user' export function useRemixPresence(): RemixPresence | null { const [activeRemixScene] = useAtom(ActiveRemixSceneAtom) @@ -25,3 +27,13 @@ export function useRemixPresence(): RemixPresence | null { return remixPresence } + +export function useMyUserId(): string | null { + const myUserId = useEditorState( + Substores.userState, + (store) => + isLoggedIn(store.userState.loginState) ? store.userState.loginState.user.userId : null, + 'useMyUserId myUserId', + ) + return myUserId +}