Skip to content

Commit

Permalink
add hook for my user id
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Jan 9, 2024
1 parent 7bd78cd commit f3bc4d8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions editor/src/core/shared/multiplayer-hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

0 comments on commit f3bc4d8

Please sign in to comment.