Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corel #7011

Draft
wants to merge 121 commits into
base: next
Choose a base branch
from
Draft

Corel #7011

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
28eccf4
feat(sanity): add `perspective` sticky parameter
juice49 Sep 3, 2024
06f7219
feat(preview): add `unstable_observeDocument(s)` to preview store (#7…
bjoerge Jul 22, 2024
92e6163
feat(preview): add support for live document id sets (#7253)
bjoerge Jul 26, 2024
9b1f27d
feat(sanity): add 'perspective' dropdown
bjoerge May 6, 2024
5d72b8c
feat(sanity): include `_version` field in search results
juice49 Jun 21, 2024
4ec4c69
feat(types): add `_version` field to `SanityDocument` and `SanityDocu…
juice49 Jun 21, 2024
55ec5e9
fix(sanity): global perspective state restoration
juice49 Jun 24, 2024
e937af9
feat(sanity): hardcode `summerDrop` and `autumnDrop` bundles
juice49 Jun 24, 2024
aa542ca
wip: allow pairs to include multiple drafts
juice49 May 22, 2024
11148b6
feat(sanity): support versioned document ids in `getPublishedId` func…
juice49 Jun 24, 2024
22db127
feat(sanity): add `_version` field to preview observation
juice49 Jun 26, 2024
d376e79
feat(sanity): reflect checked out bundle in document lists and list p…
juice49 Jun 26, 2024
344671e
debug(sanity): add version debug output to list previews
juice49 Jun 26, 2024
ca7b93c
feat(sanity): add action to create new version based on an doc id
RitaDias Jun 25, 2024
4621a8c
feat(sanity): update document title + version popover - add new and f…
RitaDias Jun 26, 2024
f6fb3d6
chore(sanity): move versions menu to versions folder
RitaDias Jun 26, 2024
9369186
chore(sanity): update check for checking version
RitaDias Jun 26, 2024
496d333
fix(sanity): ability to add new versions to doc
RitaDias Jun 26, 2024
44a9dd1
feat(sanity): add dumb bundle and version data, add icons and hues
RitaDias Jun 26, 2024
64f8e3a
feat(sanity): update styles and don't rely on random
RitaDias Jun 26, 2024
49345e4
docs(sanity): update comments
RitaDias Jun 26, 2024
8e140e9
feat(sanity): add "latest version" menu button
RitaDias Jun 26, 2024
960d7ab
refactor(sanity): update comments
RitaDias Jun 26, 2024
af11c39
chore(sanity): remove import from format date. will use something else
RitaDias Jun 26, 2024
5cb7b5b
fix(sanity): allow uppercase characters in version identifiers
juice49 Jun 26, 2024
124f794
feat(sanity): add tag to list document versions request
juice49 Jun 27, 2024
034ab4a
feat(corel): integrate bundles store (#7040)
pedrobonamin Jul 1, 2024
1f79630
feat(corel): doc and structure updates (#7039)
RitaDias Jul 1, 2024
3abad23
feat(releases): initialising releases plugin (#7048)
jordanl17 Jul 2, 2024
4c6a409
refactor(releases): removing shortRelativeDate (#7051)
jordanl17 Jul 2, 2024
a5b1709
chore(corel): add bundles provider (#7054)
pedrobonamin Jul 3, 2024
00bb78a
feat(COREL): update types to bundle + add create bundle functionality…
RitaDias Jul 5, 2024
af171cd
refactor(COREL): refactor version context & renaming (#7071)
RitaDias Jul 5, 2024
96080cd
fix(corel): update uses of collate, add typeguard for bundles and add…
pedrobonamin Jul 8, 2024
85e13b9
feat(releases): archive and unarchive releases (#7072)
jordanl17 Jul 8, 2024
042c436
refactor(sanity): move bundle metadata store to resource cache
juice49 Jul 7, 2024
5564562
feat(corel): remove version documents when deleting bundle (#7107)
pedrobonamin Jul 11, 2024
841a9cb
feat(corel): releases details screen. (#7092)
pedrobonamin Jul 11, 2024
38f9ccf
test(COREL): add core tests (#7119)
RitaDias Jul 12, 2024
ed148f1
feat(sanity): #TEMPORARY #DELETE handle versions in `DocumentPaneProv…
juice49 Jul 14, 2024
4650583
fix(sanity): avoid fetching in a loop
juice49 Jul 14, 2024
6a832fc
fix(corel): refactor version history to fetch all release documents (…
pedrobonamin Jul 15, 2024
2dbb602
refactor(COREL): update title & date validation (#7148)
RitaDias Jul 15, 2024
ad55f8d
chore: hide publish date (#7162)
RitaDias Jul 16, 2024
73c182d
feat(releases): last edited and document count in bundle (#7124)
jordanl17 Jul 16, 2024
59d6d51
feat(corel): Add review changes screen (#7155)
pedrobonamin Jul 16, 2024
e49d115
chore(corel): rename bundle.name to bundle.slug (#7171)
pedrobonamin Jul 17, 2024
a0609fe
refactor: update document badge logic and navigation (#7175)
RitaDias Jul 17, 2024
e64d059
fix(structure): fixing issue with mock for sanity in DocumentPerspect…
jordanl17 Jul 18, 2024
0682fa7
feat(releases): sorting release overview table (#7159)
jordanl17 Jul 18, 2024
fa69c3d
fix(corel): update getAllVersionsOfDocument dummy getter function (#7…
pedrobonamin Jul 18, 2024
efcf4cd
feat(sanity): supporting editing bundle metadata (#7180)
jordanl17 Jul 18, 2024
da7dae6
fix: move createWrapper to test package, update name -> slug (#7177)
RitaDias Jul 19, 2024
7aa05b6
test: remove old CreateBundleDialog test
RitaDias Jul 19, 2024
0dc78ed
feat(corel): add search input to release review screen (#7213)
pedrobonamin Jul 22, 2024
39ca830
feat: add documents validation (#7207)
pedrobonamin Jul 22, 2024
0bb8c09
refactor: update GROQ query for document versions (#7208)
RitaDias Jul 23, 2024
3aeb4ea
fix(core): update useDocumentVersions to restore breaking tests (#7235)
pedrobonamin Jul 24, 2024
7c82dc8
test(releases): testing release detail/summary screen (#7230)
jordanl17 Jul 24, 2024
c34bb6d
fix(structure): update PaneItemPreview to reflect when a document is …
pedrobonamin Jul 24, 2024
00b484a
fix(core): fix lint warning in WithAddonDatasetProvider (#7240)
pedrobonamin Jul 25, 2024
976b701
feat(releases): publish all documents in a bundle (#7194)
jordanl17 Jul 25, 2024
84de2c5
chore(structure): move useDocumentVersions to PaneProvider (#7237)
pedrobonamin Jul 25, 2024
8cca670
fix(structure): update DocumentPerspective menu test (#7254)
pedrobonamin Jul 26, 2024
ea45af6
feat(releases): default sorting version documents in release (#7242)
jordanl17 Jul 26, 2024
cadfd22
chore(core): refactor useDocumentVersion to use ListenQuery (#7241)
pedrobonamin Jul 29, 2024
ce0ec66
fix(core): unify items to render in BundlesMenu (#7262)
pedrobonamin Jul 29, 2024
bd209d0
fix: releases default sort order in wrong direction (#7264)
jordanl17 Jul 29, 2024
a61fd1b
refactor(releases): use live id sets for release document list
bjoerge Jul 26, 2024
319990a
refactor: simplify data fetching and validation for bundle documents
bjoerge Jul 26, 2024
22c5388
refactor(bundles): use observeDocumentIdSet for useDocumentVersions
bjoerge Jul 26, 2024
91e6a14
fix(test): update bundles/releases tests
bjoerge Jul 29, 2024
bc0ece9
feat(core): fix infinite loading in releases and create addon dataset…
pedrobonamin Jul 30, 2024
69154d4
fix(core): update corel contexts to match new lint rules (#7332)
pedrobonamin Aug 7, 2024
1e33383
feat(corel): virtualize content releases plugin lists (#7301)
pedrobonamin Aug 8, 2024
a13af5d
refactor(sanity, release): Add translation keys (#7339)
RitaDias Aug 9, 2024
1e6387c
temp(preview): enable full document preview for now
bjoerge Jul 26, 2024
72d0aae
fix(preview): remove full document preview support
bjoerge Aug 2, 2024
f3d28d2
feat(test-studio): switch off Actions API integration; versions not c…
juice49 Jul 23, 2024
a6e655e
Revert "wip: allow pairs to include multiple drafts"
juice49 Jul 18, 2024
853b6e8
Revert "feat(sanity): #TEMPORARY #DELETE handle versions in `Document…
juice49 Jul 18, 2024
46a1b4c
feat(sanity): support viewing and editing document versions
juice49 Jul 22, 2024
6b331ef
feat(core): document diff review for new documents (#7356)
pedrobonamin Aug 13, 2024
9aa4c6d
feat(releases, core): supporting remotely deleted bundles (#7342)
jordanl17 Aug 13, 2024
46694bb
fix(structure): update document status to display the version documen…
pedrobonamin Aug 13, 2024
2d98c7d
feat: support version documents creation from document list (#7280)
pedrobonamin Aug 14, 2024
82cb2d6
fix(core): update cache dependencys for useBundlesStore (#7372)
pedrobonamin Aug 14, 2024
406b6b6
feat(releases): suffix to bundle slug (#7374)
jordanl17 Aug 15, 2024
919e0db
refactor(sanity): update version id to match `versions.[bundle].[id]`…
RitaDias Aug 16, 2024
265d274
fix(sanity): fix typo in groq query for deleting bundle
RitaDias Aug 19, 2024
da9542a
feat(releases, core): supporting banner display for remote deleted bu…
jordanl17 Aug 19, 2024
762f6ab
fix(sanity): update the title to be ellipsed when the text is too lon…
RitaDias Aug 20, 2024
d785f1c
chore(core): remove useListener hook (#7392)
pedrobonamin Aug 20, 2024
1578585
refactor(sanity): re-add sanity::versionOf (#7413)
RitaDias Aug 23, 2024
deea91a
refactor(sanity): remove commented publishat input (#7412)
RitaDias Aug 26, 2024
ff78001
refactor(sanity): allow for editing publish data on bundle form
RitaDias Aug 26, 2024
acf2415
refactor(sanity): Add toast when discarding version and for deleting …
RitaDias Aug 26, 2024
1391a34
refactor(sanity): add prop to bundleform (#7420)
RitaDias Aug 26, 2024
46f884f
chore(core): rename and move getBundleSlug to getVersionFromId
pedrobonamin Aug 26, 2024
12267df
feat(tasks): link tasks to the version documents
pedrobonamin Aug 26, 2024
9404d2b
refactor(sanity): add changes to allow for comments in version docume…
RitaDias Aug 27, 2024
0f46f32
fix(core): update how bundleSlug is obtained from the version ids (#7…
pedrobonamin Aug 28, 2024
9dfc7ca
feat: improve telemetry debugging
bjoerge Aug 28, 2024
d7683bc
fix(sanity): fix issue on useGetbundleSlug
RitaDias Aug 29, 2024
ef75e21
fix(core): remove bundle slugs in favor of bundle id (#7427)
bjoerge Aug 30, 2024
3957e82
fixup! fix(core): remove bundle slugs in favor of bundle id (#7427)
bjoerge Aug 30, 2024
c9dc8f0
fixup! fix(core): remove bundle slugs in favor of bundle id (#7427)
bjoerge Aug 30, 2024
7d070e3
fixup! fix(core): remove bundle slugs in favor of bundle id (#7427)
bjoerge Aug 30, 2024
04f9fc2
fix(core): version document's history was returning error (#7438)
jordanl17 Aug 30, 2024
9dd29a2
feat(sanity): add telemetry for versions (#7460)
RitaDias Sep 4, 2024
5d44e66
fix(core): update useReleaseHistory to fetch with the version documen…
pedrobonamin Sep 4, 2024
cb019df
feat(sanity): rename `newVersion` operation to `createVersion`
juice49 Sep 4, 2024
3c2b805
fix(core): update intent link for releases tool (#7468)
pedrobonamin Sep 5, 2024
2a08b00
feat(sanity): update document footer for versions (#7466)
RitaDias Sep 9, 2024
21b31c7
refactor(sanity, release): rename interface focused components from b…
RitaDias Sep 10, 2024
f3283b1
feat(sanity): #TEMPORARY use API vX
juice49 Aug 15, 2024
ff0d61f
feat: #TEMPORARY use `@sanity/client@bundle-perspective`
juice49 Sep 2, 2024
84ed316
feat(sanity): adopt `bundlePerspective` for listing documents
juice49 Aug 15, 2024
1956113
feat(sanity): move perspective resolution to `resolvePerspective` fun…
juice49 Sep 13, 2024
f30b97e
chore(releases): moving from bundles to releases directory (#7500)
jordanl17 Sep 20, 2024
177e88b
Revert "Revert "chore: support for sticky params in URL and intent op…
juice49 Oct 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dev/test-studio/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ const defaultWorkspace = {
icon: SanityMonogram,
// eslint-disable-next-line camelcase
__internal_serverDocumentActions: {
enabled: true,
// TODO: Switched off because Actions API doesn't support versions (yet).
enabled: false,
},
scheduledPublishing: {
enabled: true,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@repo/package.config": "workspace:*",
"@repo/test-config": "workspace:*",
"@repo/tsconfig": "workspace:*",
"@sanity/client": "^6.22.1",
"@sanity/client": "bundle-perspective",
"@sanity/eslint-config-i18n": "1.0.0",
"@sanity/eslint-config-studio": "^4.0.0",
"@sanity/mutate": "^0.10.0",
Expand Down Expand Up @@ -185,6 +185,7 @@
},
"overrides": {
"@npmcli/arborist": "^7.5.4",
"@sanity/client": "bundle-perspective",
"@sanity/ui@2": "$@sanity/ui",
"@typescript-eslint/eslint-plugin": "$@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser": "$@typescript-eslint/parser"
Expand Down
2 changes: 2 additions & 0 deletions packages/@sanity/types/src/documents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface SanityDocument {
_createdAt: string
_updatedAt: string
_rev: string
_version?: Record<string, never>
[key: string]: unknown
}

Expand All @@ -21,6 +22,7 @@ export interface SanityDocumentLike {
_createdAt?: string
_updatedAt?: string
_rev?: string
_version?: Record<string, never>
[key: string]: unknown
}

Expand Down
1 change: 1 addition & 0 deletions packages/sanity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@
"rimraf": "^3.0.2",
"rxjs": "^7.8.0",
"rxjs-exhaustmap-with-trailing": "^2.1.1",
"rxjs-mergemap-array": "^0.1.0",
"sanity-diff-patch": "^3.0.2",
"scroll-into-view-if-needed": "^3.0.3",
"semver": "^7.3.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {type SanityClient} from '@sanity/client'
import {Card, LayerProvider, ThemeProvider, ToastProvider} from '@sanity/ui'
import {buildTheme, type RootTheme} from '@sanity/ui/theme'
import {noop} from 'lodash'
import {type ReactNode, Suspense, useEffect, useState} from 'react'
import {
ChangeConnectorRoot,
Expand All @@ -18,6 +19,8 @@ import {
import {Pane, PaneContent, PaneLayout} from 'sanity/structure'
import {styled} from 'styled-components'

import {route} from '../../../../src/router'
import {RouterProvider} from '../../../../src/router/RouterProvider'
import {createMockSanityClient} from '../../../../test/mocks/mockSanityClient'
import {getMockWorkspace} from '../../../../test/testUtils/getMockWorkspaceFromConfig'

Expand All @@ -36,6 +39,8 @@ const StyledChangeConnectorRoot = styled(ChangeConnectorRoot)`
min-width: 0;
`

const router = route.create('/')

/**
* @description This component is used to wrap all tests in the providers it needs to be able to run successfully.
* It provides a mock Sanity client and a mock workspace.
Expand Down Expand Up @@ -72,37 +77,39 @@ export const TestWrapper = (props: TestWrapperProps): JSX.Element | null => {

return (
<Suspense fallback={null}>
<ThemeProvider theme={studioThemeConfig}>
<ToastProvider>
<LayerProvider>
<WorkspaceProvider workspace={mockWorkspace}>
<ResourceCacheProvider>
<SourceProvider source={mockWorkspace.unstable_sources[0]}>
<CopyPasteProvider>
<ColorSchemeProvider>
<UserColorManagerProvider>
<StyledChangeConnectorRoot
isReviewChangesOpen={false}
onOpenReviewChanges={() => {}}
onSetFocus={() => {}}
>
<PaneLayout height="fill">
<Pane id="test-pane">
<PaneContent>
<Card padding={3}>{children}</Card>
</PaneContent>
</Pane>
</PaneLayout>
</StyledChangeConnectorRoot>
</UserColorManagerProvider>
</ColorSchemeProvider>
</CopyPasteProvider>
</SourceProvider>
</ResourceCacheProvider>
</WorkspaceProvider>
</LayerProvider>
</ToastProvider>
</ThemeProvider>
<RouterProvider router={router} state={{}} onNavigate={noop}>
<ThemeProvider theme={studioThemeConfig}>
<ToastProvider>
<LayerProvider>
<WorkspaceProvider workspace={mockWorkspace}>
<ResourceCacheProvider>
<SourceProvider source={mockWorkspace.unstable_sources[0]}>
<CopyPasteProvider>
<ColorSchemeProvider>
<UserColorManagerProvider>
<StyledChangeConnectorRoot
isReviewChangesOpen={false}
onOpenReviewChanges={() => {}}
onSetFocus={() => {}}
>
<PaneLayout height="fill">
<Pane id="test-pane">
<PaneContent>
<Card padding={3}>{children}</Card>
</PaneContent>
</Pane>
</PaneLayout>
</StyledChangeConnectorRoot>
</UserColorManagerProvider>
</ColorSchemeProvider>
</CopyPasteProvider>
</SourceProvider>
</ResourceCacheProvider>
</WorkspaceProvider>
</LayerProvider>
</ToastProvider>
</ThemeProvider>
</RouterProvider>
</Suspense>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {createContext} from 'sanity/_createContext'

import type {ReleasesMetadataContextValue} from '../../core/releases/contexts/ReleasesMetadataProvider'

/**
* @internal
* @hidden
*/
export const ReleasesMetadataContext = createContext<ReleasesMetadataContextValue | null>(
'sanity/_singletons/context/releases-metadata',
null,
)
11 changes: 11 additions & 0 deletions packages/sanity/src/_singletons/context/ReleasesTableContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {createContext} from 'sanity/_createContext'

import type {TableContextValue} from '../../core/releases/tool/components/Table/TableProvider'

/**
* @internal
*/
export const TableContext = createContext<TableContextValue | null>(
'sanity/_singletons/context/releases-table',
null,
)
2 changes: 2 additions & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export * from './context/PresenceTrackerContexts'
export * from './context/PreviewCardContext'
export * from './context/ReferenceInputOptionsContext'
export * from './context/ReferenceItemRefContext'
export * from './context/ReleasesMetadataContext'
export * from './context/ReleasesTableContext'
export * from './context/ResourceCacheContext'
export * from './context/ReviewChangesContext'
export * from './context/RouterContext'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ export const CommentsListItem = memo(function CommentsListItem(props: CommentsLi
}
}, [replies])

/* TODO - once we understand how to set up with "finished" releases
we need to add a condition to the readOnly prop in this component */

const renderedReplies = useMemo(
() =>
splicedReplies.map((reply) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {CommentsContext} from 'sanity/_singletons'
import {useEditState, useSchema, useUserListWithPermissions} from '../../../hooks'
import {useCurrentUser} from '../../../store'
import {useAddonDataset, useWorkspace} from '../../../studio'
import {getPublishedId} from '../../../util'
import {getPublishedId, resolveBundlePerspective} from '../../../util'
import {
type CommentOperationsHookOptions,
useCommentOperations,
Expand Down Expand Up @@ -43,6 +43,7 @@ export interface CommentsProviderProps {
children: ReactNode
documentId: string
documentType: string
perspective?: string
type: CommentsType
sortOrder: 'asc' | 'desc'

Expand All @@ -67,7 +68,7 @@ type TransactionId = string
export const CommentsProvider = memo(function CommentsProvider(props: CommentsProviderProps) {
const {
children,
documentId,
documentId: versionOrPublishedId,
documentType,
isCommentsOpen,
onCommentsOpen,
Expand All @@ -78,20 +79,26 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
selectedCommentId,
isConnecting,
onPathOpen,
perspective,
} = props
const commentsEnabled = useCommentsEnabled()
const [status, setStatus] = useState<CommentStatus>('open')
const {client, createAddonDataset, isCreatingDataset} = useAddonDataset()
const publishedId = getPublishedId(documentId)
const editState = useEditState(publishedId, documentType, 'low')

const editState = useEditState(
getPublishedId(versionOrPublishedId),
documentType,
'default',
resolveBundlePerspective(perspective),
)
const schemaType = useSchema().get(documentType)
const currentUser = useCurrentUser()

const {name: workspaceName, dataset, projectId} = useWorkspace()

const documentValue = useMemo(() => {
return editState.draft || editState.published
}, [editState.draft, editState.published])
return editState.version || editState.draft || editState.published
}, [editState.version, editState.draft, editState.published])

const documentRevisionId = useMemo(() => documentValue?._rev, [documentValue])

Expand All @@ -112,7 +119,7 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
error,
loading,
} = useCommentsStore({
documentId: publishedId,
documentId: versionOrPublishedId,
client,
transactionsIdMap,
onLatestTransactionIdReceived: handleOnLatestTransactionIdReceived,
Expand Down Expand Up @@ -229,7 +236,7 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
client,
currentUser,
dataset,
documentId: publishedId,
documentId: versionOrPublishedId,
documentRevisionId,
documentType,
getComment,
Expand Down Expand Up @@ -257,7 +264,7 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
client,
currentUser,
dataset,
publishedId,
versionOrPublishedId,
documentRevisionId,
documentType,
getComment,
Expand All @@ -277,7 +284,7 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr

const ctxValue = useMemo(
(): CommentsContextValue => ({
documentId,
documentId: versionOrPublishedId,
documentType,

isCreatingDataset,
Expand Down Expand Up @@ -310,7 +317,7 @@ export const CommentsProvider = memo(function CommentsProvider(props: CommentsPr
mentionOptions,
}),
[
documentId,
versionOrPublishedId,
documentType,
isCreatingDataset,
status,
Expand Down
7 changes: 5 additions & 2 deletions packages/sanity/src/core/comments/store/useCommentsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {type ListenEvent, type ListenOptions, type SanityClient} from '@sanity/c
import {useCallback, useEffect, useMemo, useReducer, useRef, useState} from 'react'
import {catchError, of} from 'rxjs'

import {getPublishedId} from '../../util'
import {getPublishedId, isVersionId} from '../../util'
import {type CommentDocument, type Loadable} from '../types'
import {commentsReducer, type CommentsReducerAction, type CommentsReducerState} from './reducer'

Expand Down Expand Up @@ -64,7 +64,10 @@ export function useCommentsStore(opts: CommentsStoreOptions): CommentsStoreRetur

const didInitialFetch = useRef<boolean>(false)

const params = useMemo(() => ({documentId: getPublishedId(documentId)}), [documentId])
const params = useMemo(
() => ({documentId: isVersionId(documentId) ? documentId : getPublishedId(documentId)}),
[documentId],
)

const initialFetch = useCallback(async () => {
if (!client) {
Expand Down
Loading
Loading