@capillarytech/creatives-library 9.0.60 → 9.0.61-alpha.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "9.0.60",
4
+ "version": "9.0.61-alpha.1",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -110,9 +110,9 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
110
110
  } = prevProps;
111
111
 
112
112
  if (
113
- tags !== prevTags
114
- || injectedTags !== prevInjectedTags
115
- || selectedOfferDetails !== prevSelectedOfferDetails
113
+ !_.isEqual(tags, prevTags)
114
+ || !_.isEqual(injectedTags, prevInjectedTags)
115
+ || !_.isEqual(selectedOfferDetails, prevSelectedOfferDetails)
116
116
  || !_.isEqual(eventContextTags, prevEventContextTags)
117
117
  || !_.isEqual(waitEventContextTags, prevWaitEventContextTags)
118
118
  ) {
@@ -134,6 +134,22 @@ describe("TagList test : UNIT", () => {
134
134
  expect(() => unmount()).not.toThrow();
135
135
  });
136
136
 
137
+ it('does not regenerate tags when selectedOfferDetails gets a new [] reference with same content', () => {
138
+ const spy = jest.spyOn(TagList.prototype, 'populateTags');
139
+ const { rerender, Component, store } = initializeTagList({
140
+ selectedOfferDetails: [],
141
+ tags: TagListData.tags,
142
+ });
143
+ spy.mockClear();
144
+ rerender(
145
+ <Provider store={store}>
146
+ <Component {...buildProps({ selectedOfferDetails: [], tags: TagListData.tags })} />
147
+ </Provider>
148
+ );
149
+ expect(spy).not.toHaveBeenCalled();
150
+ spy.mockRestore();
151
+ });
152
+
137
153
  it('regenerates tags when props.tags change (componentDidUpdate)', () => {
138
154
  const { rerender, Component, store } = initializeTagList({ tags: TagListData.tags });
139
155
  const extra = [
@@ -13,6 +13,12 @@ export const VIBER_IMG_SIZE = 10000000;
13
13
  export const VIBER_VIDEO_SIZE = 209715200;
14
14
  export const charLimit = 1000;
15
15
 
16
+ /** Stable fallbacks for TagList props — inline `= []` / `|| {}` allocate new refs every render. */
17
+ export const EMPTY_OFFER_DETAILS = [];
18
+ export const EMPTY_INJECTED_TAGS = {};
19
+ export const EMPTY_TAGS = [];
20
+ export const EMPTY_TEMPLATE_DATA = {};
21
+
16
22
  export const UPLOAD_VIBER_ASSET_REQUEST = 'app/v2Containers/Viber/UPLOAD_ASSET_REQUEST';
17
23
  export const UPLOAD_VIBER_ASSET_SUCCESS = 'app/v2Containers/Viber/UPLOAD_ASSET_SUCCESS';
18
24
  export const UPLOAD_VIBER_ASSET_FAILURE = 'app/v2Containers/Viber/UPLOAD_ASSET_FAILURE';
@@ -63,6 +63,10 @@ import {
63
63
  VIBER_CAROUSEL_IMG_SIZE,
64
64
  STATIC_URL,
65
65
  DYNAMIC_URL,
66
+ EMPTY_OFFER_DETAILS,
67
+ EMPTY_INJECTED_TAGS,
68
+ EMPTY_TAGS,
69
+ EMPTY_TEMPLATE_DATA,
66
70
  } from './constants';
67
71
  import withCreatives from '../../hoc/withCreatives';
68
72
  import {
@@ -129,12 +133,12 @@ export const Viber = (props) => {
129
133
  handleClose,
130
134
  onCreateComplete,
131
135
  params,
132
- templateData = {},
136
+ templateData = EMPTY_TEMPLATE_DATA,
133
137
  actions,
134
138
  viber = {},
135
139
  getFormSubscriptionData,
136
140
  viberData = {},
137
- selectedOfferDetails = [],
141
+ selectedOfferDetails = EMPTY_OFFER_DETAILS,
138
142
  eventContextTags,
139
143
  waitEventContextTags,
140
144
  // TestAndPreviewSlidebox props
@@ -258,7 +262,7 @@ export const Viber = (props) => {
258
262
  setTemplateMediaType(VIBER_MEDIA_TYPES.TEXT);
259
263
  }
260
264
  }
261
- }, [viber.templateDetails || templateData]);
265
+ }, [params?.id, viber.templateDetails, templateData]);
262
266
 
263
267
  // Reports live message-content validity to a parent (e.g. CreativesContainer's
264
268
  // slidebox) so it can disable its own Done/Preview-and-test buttons whenever the
@@ -332,7 +336,8 @@ export const Viber = (props) => {
332
336
  globalActionsProps.fetchSchemaForEntity(query);
333
337
  };
334
338
 
335
- const tags = metaEntities?.tags?.standard || [];
339
+ const tags = metaEntities?.tags?.standard ?? EMPTY_TAGS;
340
+ const resolvedInjectedTags = injectedTags ?? EMPTY_INJECTED_TAGS;
336
341
  // tags Code end here
337
342
 
338
343
  // validation on Text area and tags validation
@@ -393,7 +398,7 @@ export const Viber = (props) => {
393
398
  onContextChange={handleOnTagsContextChange}
394
399
  location={location}
395
400
  tags={tags}
396
- injectedTags={injectedTags || {}}
401
+ injectedTags={resolvedInjectedTags}
397
402
  id="viber_tags"
398
403
  userLocale={localStorage.getItem("jlocale") || "en"}
399
404
  selectedOfferDetails={selectedOfferDetails}
@@ -882,7 +887,7 @@ export const Viber = (props) => {
882
887
  onContextChange={handleOnTagsContextChange}
883
888
  location={location}
884
889
  tags={tags}
885
- injectedTags={injectedTags || {}}
890
+ injectedTags={resolvedInjectedTags}
886
891
  id={`viber_carousel_card_tags_${cardIndex}`}
887
892
  userLocale={localStorage.getItem("jlocale") || "en"}
888
893
  selectedOfferDetails={selectedOfferDetails}
@@ -1260,7 +1265,7 @@ export const Viber = (props) => {
1260
1265
  onContextChange={handleOnTagsContextChange}
1261
1266
  location={location}
1262
1267
  tags={tags}
1263
- injectedTags={injectedTags || {}}
1268
+ injectedTags={resolvedInjectedTags}
1264
1269
  userLocale={localStorage.getItem("jlocale") || "en"}
1265
1270
  selectedOfferDetails={selectedOfferDetails}
1266
1271
  eventContextTags={eventContextTags}
@@ -1578,15 +1583,16 @@ export const Viber = (props) => {
1578
1583
  </CapButton>
1579
1584
  </ViberFooter>
1580
1585
  </CapSpin>
1581
- {/* Test and Preview Slidebox */}
1582
- <TestAndPreviewSlidebox
1583
- show={showTestAndPreviewSlidebox || propsShowTestAndPreviewSlidebox}
1584
- onClose={handleCloseTestAndPreview}
1585
- channel={VIBER}
1586
- formData={getTemplateContent()} // Pass templateContent as formData (contains all payload fields)
1587
- content={getTemplateContent()} // Also pass as content for preview (contains viberPreviewContent)
1588
- formatMessage={formatMessage}
1589
- />
1586
+ {(showTestAndPreviewSlidebox || propsShowTestAndPreviewSlidebox) && (
1587
+ <TestAndPreviewSlidebox
1588
+ show={showTestAndPreviewSlidebox || propsShowTestAndPreviewSlidebox}
1589
+ onClose={handleCloseTestAndPreview}
1590
+ channel={VIBER}
1591
+ formData={getTemplateContent()}
1592
+ content={getTemplateContent()}
1593
+ formatMessage={formatMessage}
1594
+ />
1595
+ )}
1590
1596
  </>
1591
1597
  );
1592
1598
  };