@coorpacademy/app-review 0.14.4 → 0.14.5-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +6 -1
- package/es/configure-store.js +2 -1
- package/es/types/common.d.ts +3 -1
- package/es/types/slides.d.ts +1 -0
- package/es/views/slides/map-api-slide-to-ui.js +23 -1
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +6 -1
- package/lib/configure-store.js +2 -1
- package/lib/types/common.d.ts +3 -1
- package/lib/types/slides.d.ts +1 -0
- package/lib/views/slides/map-api-slide-to-ui.js +23 -1
- package/package.json +2 -2
|
@@ -18,4 +18,4 @@ export declare type ReceivedSlide = {
|
|
|
18
18
|
slideRef: string;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => Promise<void>;
|
|
21
|
+
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services, appendVideoOptions }: ThunkOptions) => Promise<void>;
|
|
@@ -6,7 +6,7 @@ import { setCurrentSlide } from '../ui/slides';
|
|
|
6
6
|
export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
7
7
|
export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
8
8
|
export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
9
|
-
export const fetchSlide = (slideRef) => async (dispatch, getState, { services }) => {
|
|
9
|
+
export const fetchSlide = (slideRef) => async (dispatch, getState, { services, appendVideoOptions }) => {
|
|
10
10
|
const action = buildTask({
|
|
11
11
|
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
12
12
|
bailout: (state) => {
|
|
@@ -25,6 +25,11 @@ export const fetchSlide = (slideRef) => async (dispatch, getState, { services })
|
|
|
25
25
|
const state = getState();
|
|
26
26
|
const slides = get('data.progression.state.slides', state);
|
|
27
27
|
if (isEmpty(slides)) {
|
|
28
|
+
const slideMedia = get('question.medias.0', slideFromAPI);
|
|
29
|
+
if (slideMedia && slideMedia.type === 'video') {
|
|
30
|
+
const props = (await appendVideoOptions(slideMedia));
|
|
31
|
+
slideFromAPI.question.medias = [props];
|
|
32
|
+
}
|
|
28
33
|
dispatch(setCurrentSlide(slideFromAPI));
|
|
29
34
|
}
|
|
30
35
|
}
|
package/es/configure-store.js
CHANGED
|
@@ -12,7 +12,8 @@ export default function configureStore(options) {
|
|
|
12
12
|
: compose;
|
|
13
13
|
const thunkOptions = {
|
|
14
14
|
services: options.services || getServices(),
|
|
15
|
-
callbackOnViewChanged: options.callbackOnViewChanged
|
|
15
|
+
callbackOnViewChanged: options.callbackOnViewChanged,
|
|
16
|
+
appendVideoOptions: options.appendVideoOptions
|
|
16
17
|
};
|
|
17
18
|
const thunkMiddleware = thunk.withExtraArgument(thunkOptions);
|
|
18
19
|
const enhancer = _compose(applyMiddleware(thunkMiddleware));
|
package/es/types/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Services } from '@coorpacademy/review-services';
|
|
1
|
+
import type { Services, VideoMedia } from '@coorpacademy/review-services';
|
|
2
2
|
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
3
3
|
[P in K]-?: T[P];
|
|
4
4
|
};
|
|
@@ -21,9 +21,11 @@ export declare type AppOptions = ConnectedOptions & {
|
|
|
21
21
|
skillRef?: string;
|
|
22
22
|
services?: Services;
|
|
23
23
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
24
|
+
appendVideoOptions: (media: VideoMedia) => Promise<unknown>;
|
|
24
25
|
};
|
|
25
26
|
export declare type ThunkOptions = {
|
|
26
27
|
callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
|
|
28
|
+
appendVideoOptions: (media: VideoMedia) => Promise<unknown>;
|
|
27
29
|
services: Services;
|
|
28
30
|
};
|
|
29
31
|
export declare type Options = {
|
package/es/types/slides.d.ts
CHANGED
|
@@ -163,13 +163,35 @@ const getAnswerUIModel = (question, answers, dispatch, translate) => {
|
|
|
163
163
|
throw new Error(`${type} is not an handled question.type`);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
+
const getMedia = (media) => {
|
|
167
|
+
if (!media)
|
|
168
|
+
return;
|
|
169
|
+
const { type } = media;
|
|
170
|
+
const resource = get('src.0', media);
|
|
171
|
+
switch (type) {
|
|
172
|
+
case 'img':
|
|
173
|
+
case 'audio':
|
|
174
|
+
return {
|
|
175
|
+
...resource,
|
|
176
|
+
type,
|
|
177
|
+
url: get('url', resource)
|
|
178
|
+
};
|
|
179
|
+
case 'video':
|
|
180
|
+
return {
|
|
181
|
+
...resource,
|
|
182
|
+
type
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
166
186
|
export const mapApiSlideToUi = (dispatch, translate) => (slide, answers) => {
|
|
167
187
|
const questionText = getOr('', 'question.header', slide);
|
|
188
|
+
const media = get('question.medias.0', slide);
|
|
168
189
|
return {
|
|
169
190
|
questionText,
|
|
170
191
|
answerUI: {
|
|
171
192
|
model: getAnswerUIModel(slide.question, answers, dispatch, translate),
|
|
172
|
-
help: getHelp(slide)
|
|
193
|
+
help: getHelp(slide),
|
|
194
|
+
media: getMedia(media)
|
|
173
195
|
}
|
|
174
196
|
};
|
|
175
197
|
};
|
|
@@ -18,4 +18,4 @@ export declare type ReceivedSlide = {
|
|
|
18
18
|
slideRef: string;
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
|
-
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: ThunkOptions) => Promise<void>;
|
|
21
|
+
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services, appendVideoOptions }: ThunkOptions) => Promise<void>;
|
|
@@ -12,7 +12,7 @@ const slides_1 = require("../ui/slides");
|
|
|
12
12
|
exports.SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
13
13
|
exports.SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
14
14
|
exports.SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
15
|
-
const fetchSlide = (slideRef) => async (dispatch, getState, { services }) => {
|
|
15
|
+
const fetchSlide = (slideRef) => async (dispatch, getState, { services, appendVideoOptions }) => {
|
|
16
16
|
const action = (0, redux_task_1.default)({
|
|
17
17
|
types: [exports.SLIDE_FETCH_REQUEST, exports.SLIDE_FETCH_SUCCESS, exports.SLIDE_FETCH_FAILURE],
|
|
18
18
|
bailout: (state) => {
|
|
@@ -31,6 +31,11 @@ const fetchSlide = (slideRef) => async (dispatch, getState, { services }) => {
|
|
|
31
31
|
const state = getState();
|
|
32
32
|
const slides = (0, get_1.default)('data.progression.state.slides', state);
|
|
33
33
|
if ((0, isEmpty_1.default)(slides)) {
|
|
34
|
+
const slideMedia = (0, get_1.default)('question.medias.0', slideFromAPI);
|
|
35
|
+
if (slideMedia && slideMedia.type === 'video') {
|
|
36
|
+
const props = (await appendVideoOptions(slideMedia));
|
|
37
|
+
slideFromAPI.question.medias = [props];
|
|
38
|
+
}
|
|
34
39
|
dispatch((0, slides_1.setCurrentSlide)(slideFromAPI));
|
|
35
40
|
}
|
|
36
41
|
}
|
package/lib/configure-store.js
CHANGED
|
@@ -17,7 +17,8 @@ function configureStore(options) {
|
|
|
17
17
|
: redux_1.compose;
|
|
18
18
|
const thunkOptions = {
|
|
19
19
|
services: options.services || (0, review_services_1.getServices)(),
|
|
20
|
-
callbackOnViewChanged: options.callbackOnViewChanged
|
|
20
|
+
callbackOnViewChanged: options.callbackOnViewChanged,
|
|
21
|
+
appendVideoOptions: options.appendVideoOptions
|
|
21
22
|
};
|
|
22
23
|
const thunkMiddleware = redux_thunk_1.default.withExtraArgument(thunkOptions);
|
|
23
24
|
const enhancer = _compose((0, redux_1.applyMiddleware)(thunkMiddleware));
|
package/lib/types/common.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Services } from '@coorpacademy/review-services';
|
|
1
|
+
import type { Services, VideoMedia } from '@coorpacademy/review-services';
|
|
2
2
|
export declare type WithRequired<T, K extends keyof T> = T & {
|
|
3
3
|
[P in K]-?: T[P];
|
|
4
4
|
};
|
|
@@ -21,9 +21,11 @@ export declare type AppOptions = ConnectedOptions & {
|
|
|
21
21
|
skillRef?: string;
|
|
22
22
|
services?: Services;
|
|
23
23
|
callbackOnViewChanged?: (viewName: ViewName) => void;
|
|
24
|
+
appendVideoOptions: (media: VideoMedia) => Promise<unknown>;
|
|
24
25
|
};
|
|
25
26
|
export declare type ThunkOptions = {
|
|
26
27
|
callbackOnViewChanged?: AppOptions['callbackOnViewChanged'];
|
|
28
|
+
appendVideoOptions: (media: VideoMedia) => Promise<unknown>;
|
|
27
29
|
services: Services;
|
|
28
30
|
};
|
|
29
31
|
export declare type Options = {
|
package/lib/types/slides.d.ts
CHANGED
|
@@ -167,13 +167,35 @@ const getAnswerUIModel = (question, answers, dispatch, translate) => {
|
|
|
167
167
|
throw new Error(`${type} is not an handled question.type`);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
+
const getMedia = (media) => {
|
|
171
|
+
if (!media)
|
|
172
|
+
return;
|
|
173
|
+
const { type } = media;
|
|
174
|
+
const resource = (0, fp_1.get)('src.0', media);
|
|
175
|
+
switch (type) {
|
|
176
|
+
case 'img':
|
|
177
|
+
case 'audio':
|
|
178
|
+
return {
|
|
179
|
+
...resource,
|
|
180
|
+
type,
|
|
181
|
+
url: (0, fp_1.get)('url', resource)
|
|
182
|
+
};
|
|
183
|
+
case 'video':
|
|
184
|
+
return {
|
|
185
|
+
...resource,
|
|
186
|
+
type
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
};
|
|
170
190
|
const mapApiSlideToUi = (dispatch, translate) => (slide, answers) => {
|
|
171
191
|
const questionText = (0, fp_1.getOr)('', 'question.header', slide);
|
|
192
|
+
const media = (0, fp_1.get)('question.medias.0', slide);
|
|
172
193
|
return {
|
|
173
194
|
questionText,
|
|
174
195
|
answerUI: {
|
|
175
196
|
model: getAnswerUIModel(slide.question, answers, dispatch, translate),
|
|
176
|
-
help: getHelp(slide)
|
|
197
|
+
help: getHelp(slide),
|
|
198
|
+
media: getMedia(media)
|
|
177
199
|
}
|
|
178
200
|
};
|
|
179
201
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5-alpha.8+e51b2ed20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"webpack-cli": "^4.10.0",
|
|
75
75
|
"webpack-dev-server": "^4.11.1"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "e51b2ed20cb6feaf177a880600a10e922208e6e0"
|
|
78
78
|
}
|