Skip to content
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
40 changes: 34 additions & 6 deletions src/entities/activity/lib/services/AnswersUploadService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@
checks: CheckFilesUploadResults,
fileId: string,
): CheckFileUploadResult {
return checks.find(x => x.fileId === fileId)!;

Check warning on line 111 in src/entities/activity/lib/services/AnswersUploadService.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/entities/activity/lib/services/AnswersUploadService.ts#L111

Forbidden non-null assertion (@typescript-eslint/no-non-null-assertion)
}

private getFileId(file: MediaFile): string {
return `${this.createdAt!.toString()}/${file.fileName}`;

Check warning on line 115 in src/entities/activity/lib/services/AnswersUploadService.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/entities/activity/lib/services/AnswersUploadService.ts#L115

Forbidden non-null assertion (@typescript-eslint/no-non-null-assertion)
}

private isFileUrl(url: string): boolean {
Expand Down Expand Up @@ -223,7 +223,7 @@
remoteUrl = uploadRecord.remoteUrl;
}

return remoteUrl!;

Check warning on line 226 in src/entities/activity/lib/services/AnswersUploadService.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/entities/activity/lib/services/AnswersUploadService.ts#L226

Forbidden non-null assertion (@typescript-eslint/no-non-null-assertion)
} catch (error) {
throw new Error(
`[UploadAnswersService.processFileUpload]: Error occurred while file ${logFileInfo} uploading\n\n${error}`,
Expand Down Expand Up @@ -266,7 +266,7 @@

const itemsAnswers = [...body.answers] as ObjectAnswerDto[];

const updatedAnswers = [];
const updatedAnswers: AnswerDto[] = [];
let logAnswerIndex = -1;
this.uploadProgressObservable.currentFile = -1;

Expand Down Expand Up @@ -318,19 +318,47 @@
remoteUrls.push(remoteUrl);
}

const isSvg = mediaAnswer.type === 'image/svg';
const isSvg = !isUnityItem && mediaAnswer?.type === 'image/svg';

if (remoteUrls.length && !isSvg) {
updatedAnswers.push({ value: remoteUrls, text });
} else if (remoteUrls.length) {
if (!remoteUrls.length) {
continue;
}

if (isSvg) {
const svgValue = itemAnswer.value as DrawerAnswerDto;

const copy: ObjectAnswerDto = {
text,
value: { ...svgValue, uri: remoteUrls[0] },
};

if (text !== undefined) {
copy.text = text;
}

updatedAnswers.push(copy);
continue;
}

if (isUnityItem) {
const unityAnswer: ObjectAnswerDto = {
value: remoteUrls,
};

if (text !== undefined) {
unityAnswer.text = text;
}

updatedAnswers.push(unityAnswer);
} else {
const mediaAnswerWithUrl: ObjectAnswerDto = {
value: remoteUrls[0],
};

if (text !== undefined) {
mediaAnswerWithUrl.text = text;
}

updatedAnswers.push(mediaAnswerWithUrl);
}
}

Expand Down Expand Up @@ -454,8 +482,8 @@

const userPublicKey = this.encryptionManager.getPublicKey({
privateKey: userPrivateKey,
appletPrime: JSON.parse(appletEncryption.prime),

Check warning on line 485 in src/entities/activity/lib/services/AnswersUploadService.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/entities/activity/lib/services/AnswersUploadService.ts#L485

Unsafe assignment of an `any` value (@typescript-eslint/no-unsafe-assignment)
appletBase: JSON.parse(appletEncryption.base),

Check warning on line 486 in src/entities/activity/lib/services/AnswersUploadService.ts

View workflow job for this annotation

GitHub Actions / ESLint

src/entities/activity/lib/services/AnswersUploadService.ts#L486

Unsafe assignment of an `any` value (@typescript-eslint/no-unsafe-assignment)
});

const encryptedData: ActivityAnswersRequest = {
Expand Down
22 changes: 11 additions & 11 deletions src/entities/unity/ui/tmp-fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export const testJson = {
m_fLightTemp: 6440.0,
m_fLightIntensity: 1.399999976158142,
m_qLightRot: {
x: 0.30467337369918826,
y: 0.22434665262699128,
x: 0.304673,
y: 0.224347,
z: -0.1939675658941269,
w: 0.9051073789596558,
},
m_sSkyPrefab: 'Epic_GloriousPink_EquiRect',
m_bIsFog: false,
m_colorFog: {
r: 0.13317199051380158,
r: 0.133172,
g: 0.5796447992324829,
b: 0.6301887035369873,
a: 1.0,
Expand All @@ -41,14 +41,14 @@ export const testJson = {
TaskTargetData: {
m_name: 'RotorParent',
m_pos: {
x: 0.7515307664871216,
y: 3.9503118991851808,
z: 0.6578241586685181,
x: 0.751531,
y: 3.950312,
z: 0.657824,
},
m_rot: {
x: 0.02263173833489418,
y: 0.4130081534385681,
z: -0.010267139412462712,
z: -0.010267,
w: 0.9103882312774658,
},
},
Expand All @@ -66,7 +66,7 @@ export const testJson = {
m_qRot: {
x: 0.02263173833489418,
y: 0.4130081534385681,
z: -0.010267139412462712,
z: -0.010267,
w: 0.9103882312774658,
},
m_v3IndicatorPos: {
Expand Down Expand Up @@ -105,7 +105,7 @@ export const testJson = {
m_qRot: {
x: 0.02263173833489418,
y: 0.4130081534385681,
z: -0.010267139412462712,
z: -0.010267,
w: 0.9103882312774658,
},
m_v3IndicatorPos: {
Expand Down Expand Up @@ -143,7 +143,7 @@ export const testJson = {
m_qRot: {
x: 0.02263173833489418,
y: 0.4130081534385681,
z: -0.010267139412462712,
z: -0.010267,
w: 0.9103882312774658,
},
m_v3IndicatorPos: {
Expand Down Expand Up @@ -181,7 +181,7 @@ export const testJson = {
m_qRot: {
x: 0.02263173833489418,
y: 0.4130081534385681,
z: -0.010267139412462712,
z: -0.010267,
w: 0.9103882312774658,
},
m_v3IndicatorPos: {
Expand Down
1 change: 1 addition & 0 deletions src/features/pass-survey/lib/types/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ type PipelineItemBase = {
name?: string;
type: ActivityItemType;
payload: PipelinePayload;
isUnity?: boolean;
isSkippable?: boolean;
isAbleToMoveBack?: boolean;
canBeReset?: boolean;
Expand Down
22 changes: 15 additions & 7 deletions src/features/pass-survey/model/hooks/useActivityStepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ export function useActivityStepper(state: ActivityState | undefined) {

const currentPipelineItem = state?.items[step];

const isTutorialStep = currentPipelineItem?.type === 'Tutorial';
const isAbTestStep = currentPipelineItem?.type === 'AbTest';
const isMessageStep = currentPipelineItem?.type === 'Message';
const isSplashStep = currentPipelineItem?.type === 'Splash';
const currentType =
typeof currentPipelineItem?.type === 'string'
? currentPipelineItem?.type.trim().toLowerCase()
: undefined;

const isTutorialStep = currentType === 'tutorial';
const isAbTestStep = currentType === 'abtest';
const isMessageStep = currentType === 'message';
const isSplashStep = currentType === 'splash';
const isFirstStep = step === 0;
const isLastStep = items && step === items.length - 1;

Expand Down Expand Up @@ -55,9 +60,11 @@ export function useActivityStepper(state: ActivityState | undefined) {
const canMoveBack = currentPipelineItem?.isAbleToMoveBack;
const canReset =
currentPipelineItem?.canBeReset && (hasAnswer || hasAdditionalAnswer);
const showTopNavigation = currentPipelineItem?.hasTopNavigation;
const showBottomNavigation = !showTopNavigation;
const showWatermark = !isSplashStep && !showTopNavigation;
const isUnityStep = currentPipelineItem?.isUnity ?? currentType === 'unity';
const showTopNavigation =
currentPipelineItem?.hasTopNavigation && !isUnityStep;
const showBottomNavigation = !showTopNavigation && !isUnityStep;
const showWatermark = !isSplashStep && !showTopNavigation && !isUnityStep;

const isConditionalLogicItem = ConditionalLogicItems.includes(
currentPipelineItem!?.type,
Expand Down Expand Up @@ -95,6 +102,7 @@ export function useActivityStepper(state: ActivityState | undefined) {
showTopNavigation,
showBottomNavigation,

isUnityStep,
isValid,
getNextButtonText,
};
Expand Down
1 change: 1 addition & 0 deletions src/features/pass-survey/model/pipelineBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function buildPipeline(activity: ActivityDetails): PipelineItem[] {
id: item.id,
name: item.name,
type: item.inputType,
isUnity: true,
payload: item.config,
question: item.question,
isSkippable: item.isSkippable,
Expand Down
11 changes: 10 additions & 1 deletion src/features/pass-survey/ui/ActivityItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { FlankerGameResponse } from '@app/entities/flanker/lib/types/response';
import { HtmlFlanker } from '@app/entities/flanker/ui/HtmlFlanker/HtmlFlanker';
import { NativeIosFlanker } from '@app/entities/flanker/ui/NativeIosFlanker/NativeIosFlanker';
import { StabilityTracker } from '@app/entities/stabilityTracker/ui/StabilityTracker';
import { UnityResult } from '@app/entities/unity/lib/types/unityType';
import { IS_ANDROID } from '@app/shared/lib/constants';
import { LiveEvent } from '@app/shared/lib/tcp/types';
import { useSendEvent } from '@app/shared/lib/tcp/useSendLiveEvent';
Expand Down Expand Up @@ -154,6 +155,14 @@ export function ActivityItem({
[moveToNextItem, onResponse],
);

const handleUnityComplete = useCallback(
(response: UnityResult) => {
onResponse(response);
moveToNextItem();
},
[moveToNextItem, onResponse],
);

const {
question = pipelineItem.question,
item,
Expand Down Expand Up @@ -448,7 +457,7 @@ export function ActivityItem({
<Box flex={1}>
<UnityView
payload={pipelineItem.payload}
onResponse={onResponse}
onResponse={handleUnityComplete}
/>
</Box>
),
Expand Down
Loading
Loading