Skip to content

Commit

Permalink
refactor(structure): move CommentsContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 6555ffc commit 94950b7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 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 @@ -27,6 +27,7 @@ export * from './presence/FormFieldPresenceContext'
export * from './router/RouterContext'
export * from './store/_legacy/ResourceCacheContext'
export * from './structure/comments/authoring-path/CommentsAuthoringPathContext'
export * from './structure/comments/CommentsContext'
export * from './structure/comments/components/pte/comment-input/CommentInputContext'
export * from './structure/components/pane/PaneContext'
export * from './structure/panes/document/DocumentPaneContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {createContext} from 'react'

import {type CommentsContextValue} from './types'
import {CommentsContextValue} from '../../../core/comments/context/comments/types'

/**
* @internal
*/
export const CommentsContext = createContext<CommentsContextValue | null>(null)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {type Path} from '@sanity/types'
import {orderBy} from 'lodash'
import {memo, type ReactNode, useCallback, useMemo, useState} from 'react'
import {CommentsContext} from 'sanity/_singletons'

import {useEditState, useSchema, useUserListWithPermissions} from '../../../hooks'
import {useCurrentUser} from '../../../store'
Expand All @@ -19,8 +20,7 @@ import {
type CommentThreadItem,
type CommentUpdatePayload,
} from '../../types'
import {buildCommentThreadItems} from '../../utils'
import {CommentsContext} from './CommentsContext'
import {buildCommentThreadItems} from '../../utils/buildCommentThreadItems'
import {type CommentsContextValue} from './types'

const EMPTY_ARRAY: [] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './CommentsContext'
export * from './CommentsProvider'
2 changes: 1 addition & 1 deletion packages/sanity/src/core/comments/hooks/useComments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useContext} from 'react'
import {CommentsContext} from 'sanity/_singletons'

import {CommentsContext} from '../context'
import {type CommentsContextValue} from '../context/comments/types'

/**
Expand Down

0 comments on commit 94950b7

Please sign in to comment.