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

VC-1438 – Leader view manual release unlock delay #647

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
30 changes: 22 additions & 8 deletions src/components/AdventureStepReportCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<Modalize>(null);
const { t } = useTranslation('manageGroup');
const { height } = Dimensions.get('window');
Expand Down Expand Up @@ -107,10 +109,18 @@ function AdventureStepReportCard({
}, [currentStep, isLocked, isManual]);

const unlockNextStep = async (advId: string): Promise<void> => {
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);
Expand Down Expand Up @@ -146,7 +156,7 @@ function AdventureStepReportCard({
},
],
);
}
} */
};

const onUnlockNextStep = (advId: string): void => {
Expand Down Expand Up @@ -220,15 +230,19 @@ function AdventureStepReportCard({
</View>
<View style={styles.action}>
{isNext ? (
<OldButton
onPress={() => onUnlockNextStep(adventure.id)}
style={styles.actionReleaseNow}
<Button
size="s"
radius="m"
color="secondary"
isLoading={isUnlocking}
style={{ paddingVertical: theme.spacing.s }}
onPress={(): void => {
onUnlockNextStep(adventure.id);
}}
testID="ctaReleaseNow"
>
<Text style={styles.actionReleaseNowLabel}>
{t('releaseNow')}
</Text>
</OldButton>
{t('releaseNow')}
</Button>
) : isLocked ? (
<VokeIcon
name={'lock'}
Expand Down
5 changes: 4 additions & 1 deletion src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ const Button: FunctionComponent<ButtonProps> = ({
<Text style={stylesText}>{isLoading ? ' ' : children}</Text>
{!!isLoading && (
<View style={{ position: 'absolute', alignSelf: 'center' }}>
<ActivityIndicator size="small" color="#216373" />
<ActivityIndicator
size="small"
color={color === 'secondary' ? '#fff' : '#216373'}
/>
</View>
)}
</View>
Expand Down