Skip to content

Commit

Permalink
refactor: removing undefined return type from getTransLogs when no do…
Browse files Browse the repository at this point in the history
…c IDs provided
  • Loading branch information
jordanl17 committed Dec 13, 2024
1 parent 44dedc7 commit 5a2a17a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type SanityDocument} from '@sanity/types'
import {useCallback, useEffect, useMemo, useRef} from 'react'
import {useObservable} from 'react-rx'
import {catchError, filter, forkJoin, from, map, type Observable, of, switchMap} from 'rxjs'
import {catchError, forkJoin, from, map, type Observable, of, switchMap} from 'rxjs'

import {useClient} from '../../../../../hooks/useClient'
import {getTransactionsLogs} from '../../../../../store/translog/getTransactionLogs'
Expand Down Expand Up @@ -55,7 +55,6 @@ export const useDocumentRevertStates = (documents: DocumentInRelease[]) => {
},
),
).pipe(
filter(Boolean),
map((transactions) => {
if (transactions.length === 0) throw new Error('No transactions found.')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useMemo} from 'react'
import {useObservable} from 'react-rx'
import {catchError, filter, from, map, of} from 'rxjs'
import {catchError, from, map, of} from 'rxjs'

import {useClient} from '../../../../../hooks/useClient'
import {getTransactionsLogs} from '../../../../../store/translog/getTransactionLogs'
Expand All @@ -25,7 +25,6 @@ export const usePostPublishTransactions = (documents: DocumentInRelease[]) => {
},
),
).pipe(
filter(Boolean),
// the transaction of published is also returned
// so post publish transactions will result in more than 1 transaction
map((transactions) => transactions.length > 1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export async function getTransactionsLogs(
*/
authors?: string
},
): Promise<TransactionLogEventWithEffects[] | undefined> {
): Promise<TransactionLogEventWithEffects[]> {
const clientConfig = client.config()
const dataset = clientConfig.dataset
const queryParams = new URLSearchParams({
Expand All @@ -90,8 +90,6 @@ export async function getTransactionsLogs(
}?${queryParams.toString()}`,
)

if (!documentIds.length) return undefined

const stream = await getJsonStream(transactionsUrl, clientConfig.token)
const transactions: TransactionLogEventWithEffects[] = []

Expand Down

0 comments on commit 5a2a17a

Please sign in to comment.