diff --git a/src/people/utils/AssignedUnassignedBounties.tsx b/src/people/utils/AssignedUnassignedBounties.tsx index 7797d2a8..96ce6055 100644 --- a/src/people/utils/AssignedUnassignedBounties.tsx +++ b/src/people/utils/AssignedUnassignedBounties.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useEffect, useState } from 'react'; +import React, { useMemo, useState } from 'react'; import styled from 'styled-components'; import { observer } from 'mobx-react-lite'; import { BountiesProps } from 'people/interfaces'; @@ -137,22 +137,19 @@ const Bounties = (props: BountiesProps) => { const [openConnectModal, setConnectModal] = useState(false); const closeConnectModal = () => setConnectModal(false); const showConnectModal = () => setConnectModal(true); - const [canAssignHunter, setCanAssignHunter] = useState(false); const { ui, main } = useStores(); const userPubkey = ui.meInfo?.owner_pubkey; - const checkUserRoles = useCallback(async () => { - const canAssignHunter = await userCanManageBounty(org_uuid, userPubkey, main); - const bountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey; + const canAssignHunter = useMemo(() => { + if (!org_uuid || !userPubkey) return false; - const canAssign = canAssignHunter || bountyOwner; - setCanAssignHunter(canAssign); - }, [main, org_uuid, userPubkey]); + const isBountyOwner = ui.meInfo?.owner_pubkey === person.owner_pubkey; - useEffect(() => { - checkUserRoles(); - }, [checkUserRoles]); + const canManage = userCanManageBounty(org_uuid, userPubkey, main); + + return isBountyOwner || canManage; + }, [org_uuid, userPubkey, person.owner_pubkey, main]); return ( <> diff --git a/src/people/widgetViews/workspace/WorkspacePhase.tsx b/src/people/widgetViews/workspace/WorkspacePhase.tsx index 5e32c8a2..666c95df 100644 --- a/src/people/widgetViews/workspace/WorkspacePhase.tsx +++ b/src/people/widgetViews/workspace/WorkspacePhase.tsx @@ -171,8 +171,12 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => { setIsPostBountyModalOpen(true); }; - const onPanelClick = () => { - history.push(`/feature/${props.workspace_uuid}`); + const onPanelClick = (activeWorkspace?: string, bounty?: any) => { + if (bounty?.id) { + history.push(`/bounty/${bounty.id}`); + } else { + history.push(`/feature/${props.workspace_uuid}`); + } }; const handlePhasePlannerClick = () => { @@ -260,12 +264,10 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => { ); useEffect(() => { - getTotalBounties(checkboxIdToSelectedMap); - }, [getTotalBounties, checkboxIdToSelectedMap]); - - useEffect(() => { - if (page === 1 && phases[selectedIndex]) { + if (phases[selectedIndex]) { (async () => { + setLoading(true); + await main.getPhaseBounties( phases[selectedIndex].feature_uuid, phases[selectedIndex].uuid, @@ -276,10 +278,13 @@ const WorkspacePhasingTabs = (props: WorkspacePhaseProps) => { languages: languageString } ); + + await getTotalBounties(checkboxIdToSelectedMap); + setLoading(false); })(); } - }, [languageString, phases, selectedIndex, main, page, checkboxIdToSelectedMap]); + }, [phases, selectedIndex, main, checkboxIdToSelectedMap, languageString, getTotalBounties]); useEffect(() => { const checkUserPermissions = async () => { diff --git a/src/store/main.ts b/src/store/main.ts index e40cd508..f7f6b9d1 100644 --- a/src/store/main.ts +++ b/src/store/main.ts @@ -739,7 +739,7 @@ export class MainStore { sortBy: 'created', search: uiStore.searchText ?? '', page: 1, - resetPage: false, + resetPage: true, ...params }; @@ -752,7 +752,7 @@ export class MainStore { const query2 = this.appendQueryParams( `features/${feature_uuid}/phase/${phase_uuid}/bounty`, queryLimit, - params ? queryParams : this.getWantedsPrevParams + queryParams ); try {