Skip to content

Commit 7c43faa

Browse files
committed
lint
1 parent 401d801 commit 7c43faa

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

apps/sim/hooks/queries/kb/connectors.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ async function fetchConnectorDetail(
8888
return result.data
8989
}
9090

91+
/** Stop polling for initial sync after 2 minutes */
92+
const PENDING_SYNC_WINDOW_MS = 2 * 60 * 1000
93+
94+
/**
95+
* Checks if a connector is syncing or awaiting its first sync within the allowed window
96+
*/
97+
export function isConnectorSyncingOrPending(connector: ConnectorData): boolean {
98+
if (connector.status === 'syncing') return true
99+
return (
100+
connector.status === 'active' &&
101+
!connector.lastSyncAt &&
102+
Date.now() - new Date(connector.createdAt).getTime() < PENDING_SYNC_WINDOW_MS
103+
)
104+
}
105+
91106
export function useConnectorList(knowledgeBaseId?: string) {
92107
return useQuery({
93108
queryKey: connectorKeys.list(knowledgeBaseId),
@@ -97,8 +112,8 @@ export function useConnectorList(knowledgeBaseId?: string) {
97112
placeholderData: keepPreviousData,
98113
refetchInterval: (query) => {
99114
const connectors = query.state.data
100-
const hasSyncing = connectors?.some((c) => c.status === 'syncing')
101-
return hasSyncing ? 3000 : false
115+
if (!connectors?.length) return false
116+
return connectors.some(isConnectorSyncingOrPending) ? 3000 : false
102117
},
103118
})
104119
}

apps/sim/lib/knowledge/documents/document-processor.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ async function parseDataURI(fileUrl: string, filename: string, mimeType: string)
761761

762762
const extension = filename.includes('.')
763763
? filename.split('.').pop()!.toLowerCase()
764-
: getExtensionFromMimeType(mimeType) ?? 'txt'
764+
: (getExtensionFromMimeType(mimeType) ?? 'txt')
765765
const buffer = Buffer.from(base64Data, 'base64')
766766
const result = await parseBuffer(buffer, extension)
767767
return result.content
@@ -774,9 +774,7 @@ async function parseHttpFile(
774774
): Promise<{ content: string; metadata?: FileParseMetadata }> {
775775
const buffer = await downloadFileWithTimeout(fileUrl)
776776

777-
let extension = filename.includes('.')
778-
? filename.split('.').pop()?.toLowerCase()
779-
: undefined
777+
let extension = filename.includes('.') ? filename.split('.').pop()?.toLowerCase() : undefined
780778
if (!extension && mimeType) {
781779
extension = getExtensionFromMimeType(mimeType) ?? undefined
782780
}

0 commit comments

Comments
 (0)