homeflowjs 1.0.55 → 1.0.56

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,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -22,6 +22,15 @@ const PropertiesDisplay = ({
22
22
  ...other
23
23
  }) => {
24
24
  if (!properties?.length) {
25
+ if (inserts.length > 0) {
26
+ return (
27
+ <>
28
+ {noResultsMessage}
29
+ {inserts[0]?.component}
30
+ </>
31
+ );
32
+ }
33
+
25
34
  return noResultsMessage;
26
35
  }
27
36
 
@@ -73,25 +82,22 @@ const PropertiesDisplay = ({
73
82
  && loadingNextProperties;
74
83
 
75
84
  const insertsAvailable = Array.isArray(inserts) && inserts.length > 0;
76
- const insertsFrequency =
77
- insertsAvailable && inserts[0]?.frequency > 0 ? inserts[0].frequency : null;
78
-
85
+ const insertsFrequency = insertsAvailable && inserts[0]?.frequency > 0
86
+ ? inserts[0].frequency
87
+ : null;
88
+
79
89
  const { propertiesInsertsMap, insertablePropertiesIDList } = useMemo(() => {
80
90
  const propertiesLength = properties.length;
81
- const validInserts = insertsAvailable
82
- ? inserts.filter(({ index }) => index >= 0 && index < propertiesLength)
83
- : null;
84
- if (validInserts) {
85
- const propertiesInsertsMap = new Map();
86
- for (const insert of validInserts) {
87
- const property = properties[insert.index];
88
- propertiesInsertsMap.set(property.property_id, insert);
89
- };
90
- const insertablePropertiesIDList = Array.from(propertiesInsertsMap.keys());
91
-
92
- return { propertiesInsertsMap, insertablePropertiesIDList };
93
- }
94
- return {};
91
+ const propertiesInsertsMap = new Map();
92
+
93
+ inserts.forEach((insert) => {
94
+ const property = properties[insert.index - 1] || properties[propertiesLength - 1];
95
+ propertiesInsertsMap.set(property.property_id, insert);
96
+ });
97
+
98
+ const insertablePropertiesIDList = Array.from(propertiesInsertsMap.keys());
99
+
100
+ return { propertiesInsertsMap, insertablePropertiesIDList };
95
101
  }, [properties]);
96
102
 
97
103
  const handleListElementClick = (id = null) => {
@@ -140,8 +146,8 @@ const PropertiesDisplay = ({
140
146
  if (findResult) {
141
147
  return (
142
148
  <React.Fragment key={property.property_id}>
143
- {findResult.component}
144
149
  <Item property={property} onClick={() => visitPropertyUpdate(property.property_id)} {...other} />
150
+ {findResult.component}
145
151
  </React.Fragment>
146
152
  );
147
153
  }
@@ -199,7 +205,7 @@ PropertiesDisplay.propTypes = {
199
205
  };
200
206
 
201
207
  PropertiesDisplay.defaultProps = {
202
- inserts: null,
208
+ inserts: [],
203
209
  InfiniteScrollLoader: null,
204
210
  includePreviousBtn: false,
205
211
  noResultsMessage: <p>There were no properties matching your search.</p>,
@@ -120,7 +120,7 @@ PropertyResults.defaultProps = {
120
120
  infiniteScroll: false,
121
121
  infiniteScrollLoader: null,
122
122
  noMap: false,
123
- inserts: null,
123
+ inserts: [],
124
124
  };
125
125
 
126
126
  export default PropertyResults;