Skip to content

Commit

Permalink
refactor(core): move WorkspacesContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 198df70 commit 7e3775d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ export * from './studio/NavbarContext'
export * from './studio/router/RouterHistoryContext'
export * from './studio/SourceContext'
export * from './studio/WorkspaceContext'
export * from './studio/workspaces/WorkspacesContext'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {createContext} from 'react'
import type {WorkspacesContextValue} from 'sanity'

/** @internal */
export const WorkspacesContext = createContext<WorkspacesContextValue | null>(null)
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {createContext} from 'react'

import {type WorkspaceSummary} from '../../config'

/** @internal */
export type WorkspacesContextValue = WorkspaceSummary[]

/** @internal */
export const WorkspacesContext = createContext<WorkspacesContextValue | null>(null)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ReactNode, useMemo} from 'react'
import {WorkspacesContext} from 'sanity/_singletons'

import {type Config, prepareConfig} from '../../config'
import {WorkspacesContext} from './WorkspacesContext'

/** @internal */
export interface WorkspacesProviderProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {useContext} from 'react'
import {WorkspacesContext} from 'sanity/_singletons'

import {type WorkspaceSummary} from '../../config'
import {WorkspacesContext} from './WorkspacesContext'

/** @internal */
export function useWorkspaces(): WorkspaceSummary[] {
Expand Down

0 comments on commit 7e3775d

Please sign in to comment.