@capillarytech/creatives-library 6.12.3 → 6.12.4

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/app.js CHANGED
@@ -38,6 +38,13 @@ const history = syncHistoryWithStore(browserHistory, store, {
38
38
  });
39
39
 
40
40
  const bugSnagErrorCallback = (event) => {
41
+ const { app: { releaseStage } = {} } = event || {};
42
+ if (
43
+ (releaseStage || '').includes('nightly') ||
44
+ process.env.NODE_ENV !== 'production'
45
+ ) {
46
+ return false;
47
+ }
41
48
  let userId;
42
49
  let userName;
43
50
  let userEmail;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "6.12.3",
4
+ "version": "6.12.4",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -53,7 +53,7 @@ export function checkUnicode(content) {
53
53
  }
54
54
  return false;
55
55
  }
56
- export function updateCharCount(content, isUnicodeEnabled) {
56
+ export function updateCharCount(content = '', isUnicodeEnabled) {
57
57
  if (showOptoutCount && optoutUrl === undefined && responseState === 'REQUEST') {
58
58
  Api.getUnsubscribeUrl().then((res) => {
59
59
  optoutUrl = res.response.response;
@@ -74,6 +74,7 @@ export const LineVideo = ({
74
74
  const [videoDuration, updateVideoDuration] = useState('');
75
75
  const [videoHeight, updateVideoHeight] = useState();
76
76
  const [videoWidth, updateVideoWidth] = useState();
77
+ const [isPlaying, updateIsPlaying] = useState(false);
77
78
 
78
79
 
79
80
  useEffect(() => {
@@ -338,6 +339,18 @@ export const LineVideo = ({
338
339
  updateTemplateDrawerRequirement(true);
339
340
  }, [])
340
341
 
342
+ const playVideo = (e) => {
343
+ if (e.target.paused && !isPlaying) {
344
+ e.target.play();
345
+ }
346
+ }
347
+
348
+ const pauseVideo = (e) => {
349
+ if (!e.target.paused && isPlaying) {
350
+ e.target.pause();
351
+ }
352
+ }
353
+
341
354
  const getVideoSection = () => {
342
355
  if (!isVideo) {
343
356
  return (
@@ -393,8 +406,10 @@ export const LineVideo = ({
393
406
  poster={imagePreview}
394
407
  className="line-image-src"
395
408
  onLoadedMetadata={() => updateMetadataLoaded(true)}
396
- onMouseOver={e => e.target.play()}
397
- onMouseOut={e => e.target.pause()}
409
+ onPlaying={() => updateIsPlaying(true)}
410
+ onPause={() => updateIsPlaying(false)}
411
+ onMouseOver={playVideo}
412
+ onMouseOut={pauseVideo}
398
413
  ref={videoEl}
399
414
  >
400
415
  <source src={videoSrc} type="video/mp4" />
@@ -322,18 +322,30 @@ export const LineContainer = ({
322
322
  });
323
323
  }
324
324
 
325
- const createCallback = () => {
326
- CapNotification.success({
327
- message: formatMessage(messages.lineCreateNotification),
328
- });
329
- actions.clearEditResponse();
325
+ const createCallback = (errorMessage) => {
326
+ if (!errorMessage) {
327
+ CapNotification.success({
328
+ message: formatMessage(messages.lineCreateNotification),
329
+ });
330
+ actions.clearEditResponse();
331
+ } else {
332
+ CapNotification.error({
333
+ message: errorMessage,
334
+ });
335
+ }
330
336
  }
331
337
 
332
- const editCallback = () => {
333
- CapNotification.success({
334
- message: formatMessage(messages.lineEditNotification),
335
- });
336
- actions.clearEditResponse();
338
+ const editCallback = (errorMessage) => {
339
+ if (!errorMessage) {
340
+ CapNotification.success({
341
+ message: formatMessage(messages.lineEditNotification),
342
+ });
343
+ actions.clearEditResponse();
344
+ } else {
345
+ CapNotification.error({
346
+ message: errorMessage,
347
+ });
348
+ }
337
349
  }
338
350
 
339
351
  const formatSubmitPayload = (lineWrapperContents) => {
@@ -545,15 +557,17 @@ export const LineContainer = ({
545
557
  const onCreateLine = () => {
546
558
  actions.createTemplate(
547
559
  formatSubmitPayload(lineWrapperContents),
548
- () => {
549
- // stop timer for create line
550
- stopTimer(TRACK_CREATE_LINE, {
551
- category: 'Creatives',
552
- action: TRACK_CREATE_LINE,
553
- label: getLineType(lineWrapperContents),
554
- });
555
- createCallback();
556
- onCreateComplete();
560
+ (resp, errorMessage) => {
561
+ createCallback(errorMessage);
562
+ if (!errorMessage) {
563
+ // stop timer for create line
564
+ stopTimer(TRACK_CREATE_LINE, {
565
+ category: 'Creatives',
566
+ action: TRACK_CREATE_LINE,
567
+ label: getLineType(lineWrapperContents),
568
+ });
569
+ onCreateComplete();
570
+ }
557
571
  }
558
572
  );
559
573
  }
@@ -586,15 +600,17 @@ export const LineContainer = ({
586
600
  ...formatSubmitPayload(lineWrapperContents),
587
601
  _id: params.id,
588
602
  },
589
- () => {
590
- // stop timer for edit line
591
- stopTimer(TRACK_EDIT_LINE, {
592
- category: 'Creatives',
593
- action: TRACK_EDIT_LINE,
594
- label: getLineType(lineWrapperContents),
595
- });
596
- editCallback();
597
- onCreateComplete();
603
+ (resp, errorMessage) => {
604
+ editCallback(errorMessage);
605
+ if (!errorMessage) {
606
+ // stop timer for edit line
607
+ stopTimer(TRACK_EDIT_LINE, {
608
+ category: 'Creatives',
609
+ action: TRACK_EDIT_LINE,
610
+ label: getLineType(lineWrapperContents),
611
+ });
612
+ onCreateComplete();
613
+ }
598
614
  });
599
615
  }
600
616
 
@@ -8,10 +8,10 @@ import * as types from './constants';
8
8
  export function* createTemplate({ template, callback }) {
9
9
  let errorMsg;
10
10
  try {
11
- console.log('inside line saga createTemplate@@@', template);
12
11
  const result = yield call(Api.createLineTemplate, { template });
13
- if (result.message || result.status.code === 500) {
12
+ if (result.status.code >= 400) {
14
13
  errorMsg = result.message;
14
+ throw errorMsg;
15
15
  }
16
16
  yield put({ type: types.CREATE_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
17
17
  if (callback) {
@@ -19,6 +19,9 @@ export function* createTemplate({ template, callback }) {
19
19
  }
20
20
  } catch (error) {
21
21
  yield put({ type: types.CREATE_TEMPLATE_FAILURE, error, errorMsg });
22
+ if (callback) {
23
+ callback(null, errorMsg);
24
+ }
22
25
  }
23
26
  }
24
27
  export function* uploadAsset(file, assetType, fileParams ) {
@@ -48,11 +51,10 @@ function* watchUploadAsset() {
48
51
  export function* editTemplate({ template, callback }) {
49
52
  let errorMsg;
50
53
  try {
51
- console.log('saga editTemplate line', template);
52
54
  const result = yield call(Api.createLineTemplate, {template});
53
- console.log('saga editTemplate success line', result);
54
- if (result.message || result.status.code === 500) {
55
+ if (result.status.code >= 400) {
55
56
  errorMsg = result.message;
57
+ throw errorMsg;
56
58
  }
57
59
  if (callback) {
58
60
  callback(result.response);
@@ -60,6 +62,9 @@ export function* editTemplate({ template, callback }) {
60
62
  yield put({ type: types.EDIT_TEMPLATE_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', errorMsg });
61
63
  } catch (error) {
62
64
  yield put({ type: types.EDIT_TEMPLATE_FAILURE, error, errorMsg });
65
+ if (callback) {
66
+ callback(null, errorMsg);
67
+ }
63
68
  }
64
69
  }
65
70