homeflowjs 0.13.59 → 0.13.61

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/notify.js CHANGED
@@ -1,8 +1,6 @@
1
1
  import Toastify from 'toastify-js';
2
2
  import 'toastify-js/src/toastify.css';
3
3
 
4
- import { sanitizeText } from '../utils/index';
5
-
6
4
  const notify = (message, type, config = {}) => {
7
5
  if (!message) return;
8
6
 
@@ -27,7 +25,7 @@ const notify = (message, type, config = {}) => {
27
25
  gravity: 'top',
28
26
  position: 'center',
29
27
  stopOnFocus: true,
30
- text: sanitizeText(message),
28
+ text: message,
31
29
  escapeMarkup: false,
32
30
  className,
33
31
  style,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.13.59",
3
+ "version": "0.13.61",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -70,6 +70,14 @@ const PropertiesDisplay = ({
70
70
  && hasNextPage
71
71
  && loadingNextProperties;
72
72
 
73
+ const insertsAvailable = Array.isArray(inserts) && inserts.length > 0;
74
+ const insertsFrequency =
75
+ insertsAvailable && inserts[0]?.frequency > 0 ? inserts[0].frequency : null;
76
+ const insertsIndexMap =
77
+ insertsAvailable && inserts.some((insert) => insert?.index >= 0)
78
+ ? inserts.reduce((acc, { index }) => [...acc, index], [])
79
+ : null;
80
+
73
81
  const items = propertiesByPage(properties, propertiesPagination).map((page, i) => (
74
82
  <ConditionalWrapper
75
83
  key={i}
@@ -88,14 +96,25 @@ const PropertiesDisplay = ({
88
96
  * TODO: Allow for multiple inserts
89
97
  * This code only allows one insert from the inserts array to be show at a time
90
98
  */
91
- if (inserts && (index % inserts[0].frequency) === 0 && index !== 0) {
99
+ if (insertsFrequency && (index % insertsFrequency) === 0 && index !== 0) {
92
100
  return (
93
101
  <React.Fragment key={property.property_id}>
94
102
  {inserts[0].component}
95
103
  <Item property={property} {...other} />
96
104
  </React.Fragment>
97
105
  );
106
+ } else if (insertsIndexMap && insertsIndexMap.includes(index)) {
107
+ const findResult = inserts.find(insert => insert?.index === index);
108
+ if (findResult) {
109
+ return (
110
+ <React.Fragment key={property.property_id}>
111
+ {findResult.component}
112
+ <Item property={property} {...other} />
113
+ </React.Fragment>
114
+ );
115
+ }
98
116
  }
117
+
99
118
  return (
100
119
  <Item
101
120
  key={property.property_id}
@@ -27,13 +27,16 @@ const SavePropertyButton = (props) => {
27
27
  e.preventDefault();
28
28
  e.stopPropagation();
29
29
 
30
+ const removedNotificationMessage = notificationMessage?.remove || notificationMessage;
31
+ const savedNotificationMessage = notificationMessage?.save || notificationMessage;
32
+
30
33
  if (isSaved) {
31
34
  removeSavedProperty(propertyId);
32
- notify(notificationMessage || 'Saved property removed.', 'success', notifyConfig);
35
+ notify(removedNotificationMessage || 'Saved property removed.', 'success', notifyConfig);
33
36
  } else {
34
37
  addSavedProperty(propertyId);
35
38
  Homeflow.kickEvent('saved_property_added', propertyId);
36
- notify(notificationMessage || 'Property saved.', 'success', notifyConfig);
39
+ notify(savedNotificationMessage || 'Property saved.', 'success', notifyConfig);
37
40
  }
38
41
  };
39
42
 
@@ -67,7 +70,13 @@ const SavePropertyButton = (props) => {
67
70
  SavePropertyButton.propTypes = {
68
71
  propertyId: PropTypes.number.isRequired,
69
72
  savedProperties: PropTypes.array,
70
- notificationMessage: PropTypes.string,
73
+ notificationMessage: PropTypes.oneOfType([
74
+ PropTypes.string,
75
+ PropTypes.shape({
76
+ removed: PropTypes.string,
77
+ saved: PropTypes.string,
78
+ })
79
+ ]),
71
80
  className: PropTypes.string,
72
81
  style: PropTypes.object,
73
82
  UnsavedComponent: PropTypes.element.isRequired,
@@ -29,14 +29,16 @@ const SaveSearchButton = (props) => {
29
29
 
30
30
  const toggleSearch = (e) => {
31
31
  e.preventDefault();
32
+ const removedNotificationMessage = notificationMessage?.remove || notificationMessage;
33
+ const savedNotificationMessage = notificationMessage?.save || notificationMessage;
32
34
 
33
35
  if (savedSearch) {
34
36
  removeSavedSearchAsync(savedSearch);
35
- notify((showNotification && notificationMessage) ? notificationMessage : 'Saved search removed.', 'success');
37
+ notify((showNotification && notificationMessage) ? removedNotificationMessage : 'Saved search removed.', 'success');
36
38
  } else {
37
39
  addSavedSearchAsync(search);
38
40
  Homeflow.kickEvent('saved_search_added');
39
- notify(notificationMessage || 'Search saved.', 'success');
41
+ notify(savedNotificationMessage || 'Search saved.', 'success');
40
42
  }
41
43
  };
42
44
 
@@ -61,7 +63,13 @@ SaveSearchButton.propTypes = {
61
63
  addSavedSearchAsync: PropTypes.func.isRequired,
62
64
  removeSavedSearchAsync: PropTypes.func.isRequired,
63
65
  style: PropTypes.object,
64
- notificationMessage: PropTypes.string,
66
+ notificationMessage: PropTypes.oneOfType([
67
+ PropTypes.string,
68
+ PropTypes.shape({
69
+ removed: PropTypes.string,
70
+ saved: PropTypes.string,
71
+ })
72
+ ]),
65
73
  showNotification: PropTypes.bool,
66
74
  };
67
75