From 49247386fbc899c3ca14c48bb859d3aa84c0ca06 Mon Sep 17 00:00:00 2001 From: Vlad Mitkovsky Date: Mon, 3 May 2021 23:17:16 -0300 Subject: [PATCH] =?UTF-8?q?VC-1438=20=E2=80=93=C2=A0Leader=20view=20manual?= =?UTF-8?q?=20release=20unlock=20delay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leader view manual release unlock is not updating for the leader until minutes later. Group members have episodes unlocked immediately. --- .../AdventureStepReportCard/index.tsx | 30 ++++++++++++++----- src/components/Button/index.tsx | 5 +++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/components/AdventureStepReportCard/index.tsx b/src/components/AdventureStepReportCard/index.tsx index a480697d8..74b6d8a64 100644 --- a/src/components/AdventureStepReportCard/index.tsx +++ b/src/components/AdventureStepReportCard/index.tsx @@ -15,6 +15,7 @@ import VokeIcon from 'components/VokeIcon'; import OldButton from 'components/OldButton'; import { unlockNextAdventureStep } from 'actions/requests'; import Image from 'components/Image'; +import Button from 'components/Button'; import styles from './styles'; @@ -46,6 +47,7 @@ function AdventureStepReportCard({ const [isNext, setIsNext] = useState(false); const [isManual, setIsManual] = useState(false); const [isLocked, setIsLocked] = useState(true); + const [isUnlocking, setIsUnlocking] = useState(false); const modalizeRef = useRef(null); const { t } = useTranslation('manageGroup'); const { height } = Dimensions.get('window'); @@ -107,10 +109,18 @@ function AdventureStepReportCard({ }, [currentStep, isLocked, isManual]); const unlockNextStep = async (advId: string): Promise => { + setIsUnlocking(true); + dispatch(unlockNextAdventureStep(advId)); + /* + We can't rely on the positive reply from the server here as it's causing + delay-release bugs. Instead we are waiting for the adventure steps + to download by itself after getting a positive WS message (UNLOCK_STEP_CATEGORY). + const result = await dispatch(unlockNextAdventureStep(advId)); // https://www.typescriptlang.org/docs/handbook/advanced-types.html const positiveResult = result as TAdventureSingle; const negativeResult = result as TError; + if (positiveResult.id) { // TODO: when we have results refetch adventure to have UI updated. setCurrentStep((curVal: number) => curVal + 1); @@ -146,7 +156,7 @@ function AdventureStepReportCard({ }, ], ); - } + } */ }; const onUnlockNextStep = (advId: string): void => { @@ -220,15 +230,19 @@ function AdventureStepReportCard({ {isNext ? ( - onUnlockNextStep(adventure.id)} - style={styles.actionReleaseNow} + ) : isLocked ? ( = ({ {isLoading ? ' ' : children} {!!isLoading && ( - + )}