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

feat: added check for running project-id #2251

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
YOUTUBE_CHANNEL,
} from '~/constants'
import { api } from '~/network/api'
import { useDataStore } from '~/stores/useDataStore'
import { useModal } from '~/stores/useModalStore'
import { useUserStore } from '~/stores/useUserStore'
import { sphinxBridge } from '~/testSphinxBridge'
Expand All @@ -39,6 +40,7 @@ const handleSubmitForm = async (
data: FieldValues,
sourceType: string,
setBudget: (value: number | null) => void,
setRunningProjectId: (value: string) => void,
): Promise<void> => {
const endPoint = isSource(sourceType) ? 'radar' : 'add_node'

Expand Down Expand Up @@ -111,6 +113,10 @@ const handleSubmitForm = async (
Authorization: lsatToken,
})

if (res.data.project_id) {
setRunningProjectId(res.data.project_id)
}

if (res.error) {
const { message } = res.error

Expand All @@ -122,7 +128,7 @@ const handleSubmitForm = async (
if (err.status === 402) {
await payLsat(setBudget)
await updateBudget(setBudget)
await handleSubmitForm(data, sourceType, setBudget)
await handleSubmitForm(data, sourceType, setBudget, setRunningProjectId)
} else {
let errorMessage = NODE_ADD_ERROR

Expand All @@ -147,6 +153,7 @@ export const AddContentModal = () => {
const [currentStep, setCurrentStep] = useState(0)
const { close, visible } = useModal('addContent')
const { setBudget } = useUserStore((s) => s)
const { setRunningProjectId } = useDataStore((s) => s)
const form = useForm<FormData>({ mode: 'onChange' })
const { watch, setValue, reset } = form
const [loading, setLoading] = useState(false)
Expand Down Expand Up @@ -198,7 +205,7 @@ export const AddContentModal = () => {
setLoading(true)

try {
await handleSubmitForm(data, type, setBudget)
await handleSubmitForm(data, type, setBudget, setRunningProjectId)
SuccessNotify('Content Added')
handleClose()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
28 changes: 14 additions & 14 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@

const setTeachMeAnswer = useTeachStore((s) => s.setTeachMeAnswer)

const { fetchData, setCategoryFilter, setAbortRequests, addNewNode, splashDataLoading } = useDataStore((s) => s)
const { fetchData, setCategoryFilter, setAbortRequests, addNewNode, splashDataLoading, runningProjectId } =
useDataStore((s) => s)

const { setAiSummaryAnswer, getKeyExist, aiRefId } = useAiSummaryStore((s) => s)

Expand Down Expand Up @@ -238,18 +239,16 @@
])

useEffect(() => {
const ws = new WebSocket('wss://staging.stakwork.com/cable?channel=ProjectLogChannel')

ws.onopen = () => {
console.log('WebSocket connection established')
if (!runningProjectId) {
return
}

ws.onmessage = (event) => {
console.log('Message from server:', event.data)
const ws = new WebSocket('wss://jobs.stakwork.com/cable?channel=ProjectLogChannel')

ws.onopen = () => {
let id = 'a'

id = '51998781'
id = runningProjectId

const command = {
command: 'subscribe',
Expand All @@ -259,7 +258,13 @@
// Send the command as a JSON string
ws.send(JSON.stringify(command))

console.log('Subscription command sent:', command)

Check warning on line 261 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 261 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement
console.log('WebSocket connection established')

Check warning on line 262 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 262 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement
}

ws.onmessage = (event) => {
console.log('Message from server:', event.data)

Check warning on line 266 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 266 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

// Handle the message from the server here
}

Expand All @@ -268,14 +273,9 @@
}

ws.onclose = () => {
console.log('WebSocket connection closed')

Check warning on line 276 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected console statement

Check warning on line 276 in src/components/App/index.tsx

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement
}

// Cleanup when the component is unmounted
return () => {
// ws.close()
}
}, [])
}, [runningProjectId])

useEffect(() => {
if (!splashDataLoading) {
Expand Down
5 changes: 5 additions & 0 deletions src/stores/useDataStore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
stats: TStats | null
nodeTypes: string[]
seedQuestions: string[] | null
runningProjectId: string

setTrendingTopics: (trendingTopics: Trending[]) => void
setDataNew: (data: GraphData) => void
Expand All @@ -62,6 +63,7 @@
setSources: (sources: Sources[] | null) => void
setQueuedSources: (sources: Sources[] | null) => void
setIsFetching: (_: boolean) => void
setRunningProjectId: (runningProjectId: string) => void
setHideNodeDetails: (_: boolean) => void
addNewNode: (data: FetchDataResponse) => void
updateNode: (updatedNode: NodeExtended) => void
Expand Down Expand Up @@ -129,6 +131,7 @@
abortRequest: false,
dataNew: null,
seedQuestions: null,
runningProjectId: '',
}

let abortController: AbortController | null = null
Expand Down Expand Up @@ -244,7 +247,7 @@
sidebarFilterCounts,
})
} catch (error) {
console.log(error)

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sanity.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/topics.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/initialRender.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/trendingTopics/trendingTopics.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentAnalysis.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/curationTable/curation.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addSource.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentChart.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/searchAndRender.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNode.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/seeLatest/latest.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addTweet.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/signin.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addYoutube.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/checkEnv.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addWebpage.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNodeType.cy.ts)

Unexpected console statement

Check warning on line 250 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sourcesTable/sourcesTable.cy.ts)

Unexpected console statement

if (error !== 'abort') {
set({ isLoadingNew: false, isFetching: false })
Expand Down Expand Up @@ -296,7 +299,7 @@
setHideNodeDetails: (hideNodeDetails) => set({ hideNodeDetails }),
setSeedQuestions: (questions) => set({ seedQuestions: questions }),
updateNode: (updatedNode) => {
console.log(updatedNode)

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sanity.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/topics.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/initialRender.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/trendingTopics/trendingTopics.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentAnalysis.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/curationTable/curation.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addSource.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentChart.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/searchAndRender.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNode.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/seeLatest/latest.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addTweet.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/signin.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addYoutube.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/checkEnv.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addWebpage.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNodeType.cy.ts)

Unexpected console statement

Check warning on line 302 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sourcesTable/sourcesTable.cy.ts)

Unexpected console statement
},
addNewNode: (data) => {
const { dataInitial: existingData } = get()
Expand Down Expand Up @@ -340,8 +343,10 @@
})
},
removeNode: (id) => {
console.log(id)

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / craco-build-run

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sanity.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/topics.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/initialRender.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/trendingTopics/trendingTopics.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentAnalysis.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/curationTable/curation.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addSource.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sentimentChart/sentimentChart.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/graph/searchAndRender.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNode.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/seeLatest/latest.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addTweet.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/admin/signin.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addYoutube.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/checkEnv.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addContent/addWebpage.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/addNode/addNodeType.cy.ts)

Unexpected console statement

Check warning on line 346 in src/stores/useDataStore/index.ts

View workflow job for this annotation

GitHub Actions / cypress-run (cypress/e2e/sourcesTable/sourcesTable.cy.ts)

Unexpected console statement
},

setRunningProjectId: (runningProjectId) => set({ runningProjectId }),
setAbortRequests: (abortRequest) => set({ abortRequest }),
})),
)
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ export type SubmitErrRes = {
error?: { message?: string }
data: {
ref_id: string
project_id?: string
}
}

Expand Down
Loading