diff --git a/frontend/web/components/modals/CreateSegment.tsx b/frontend/web/components/modals/CreateSegment.tsx index c3dbb6890184..2247e0206139 100644 --- a/frontend/web/components/modals/CreateSegment.tsx +++ b/frontend/web/components/modals/CreateSegment.tsx @@ -120,7 +120,6 @@ const CreateSegment: FC = ({ const [description, setDescription] = useState(segment.description) const [name, setName] = useState(segment.name) const [rules, setRules] = useState(segment.rules) - const [shouldUpdateIdentities, setShouldUpdateIdentities] = useState(false) useEffect(() => { if (segment) { setRules(segment.rules) @@ -251,7 +250,6 @@ const CreateSegment: FC = ({ resolve(true) } }) - return Promise.resolve(true) }, [valueChanged, isEdit]) useEffect(() => { setInterceptClose(onClosing) @@ -276,7 +274,6 @@ const CreateSegment: FC = ({ if (createSuccess && createSegmentData) { setSegment(createSegmentData) onComplete?.(createSegmentData) - setShouldUpdateIdentities(true) } //eslint-disable-next-line }, [createSuccess]) @@ -284,24 +281,17 @@ const CreateSegment: FC = ({ if (updateSuccess && updateSegmentData) { setSegment(updateSegmentData) onComplete?.(updateSegmentData) - setShouldUpdateIdentities(true) } //eslint-disable-next-line }, [updateSuccess]) useEffect(() => { - if ( - shouldUpdateIdentities && - tab === 2 && - environmentId && - environmentId !== 'ENVIRONMENT_API_KEY' - ) { + if (tab === 2 && environmentId) { identities?.results.forEach((identity) => AppActions.getIdentitySegments(projectId, identity.id), ) - setShouldUpdateIdentities(false) } - }, [shouldUpdateIdentities, tab, identities, projectId, environmentId]) + }, [tab, identities, projectId, environmentId]) const operators: Operator[] | null = _operators || Utils.getSegmentOperators() if (operators) { @@ -632,15 +622,20 @@ const LoadingCreateSegment: FC = (props) => { const isEdge = Utils.getIsEdge() const { data: identities, isLoading: identitiesLoading } = - useGetIdentitiesQuery({ - environmentId, - isEdge, - page: page.number, - pageType: page.pageType, - page_size: 10, - pages: page.pages, - search, - }) + useGetIdentitiesQuery( + { + environmentId, + isEdge, + page: page.number, + pageType: page.pageType, + page_size: 10, + pages: page.pages, + search, + }, + { + skip: !environmentId, + }, + ) return isLoading ? (
diff --git a/frontend/web/components/modals/CreateSegmentUsersTabContent.tsx b/frontend/web/components/modals/CreateSegmentUsersTabContent.tsx index 9d9e31a38484..79ad7e7a0134 100644 --- a/frontend/web/components/modals/CreateSegmentUsersTabContent.tsx +++ b/frontend/web/components/modals/CreateSegmentUsersTabContent.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react' +import React from 'react' import EnvironmentSelect from 'components/EnvironmentSelect' import IdentitySegmentsProvider from 'common/providers/IdentitySegmentsProvider' import PanelSearch from 'components/PanelSearch' @@ -35,10 +35,6 @@ const CreateSegmentUsersTabContent: React.FC< setPage, setSearchInput, }) => { - useEffect(() => { - console.log({ identities }) - }, [identities]) - return (
diff --git a/frontend/web/components/pages/SegmentsPage.tsx b/frontend/web/components/pages/SegmentsPage.tsx index 53cef1cfc359..ed348134af2d 100644 --- a/frontend/web/components/pages/SegmentsPage.tsx +++ b/frontend/web/components/pages/SegmentsPage.tsx @@ -40,8 +40,7 @@ type SegmentsPageType = { const SegmentsPage: FC = (props) => { const { projectId } = props.match.params - const environmentId = - ProjectStore.getEnvironment()?.api_key || 'ENVIRONMENT_API_KEY' + const environmentId = ProjectStore.getEnvironment()?.api_key const params = Utils.fromParam() const id = params.id const { search, searchInput, setSearchInput } = useSearchThrottle('')