homeflowjs 0.13.63 → 0.13.64
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,4 +1,4 @@
|
|
1
|
-
import React, { useEffect, useRef } from 'react';
|
1
|
+
import React, { useEffect, useRef, useMemo } from 'react';
|
2
2
|
import { connect, useSelector } from 'react-redux';
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
|
@@ -73,10 +73,24 @@ const PropertiesDisplay = ({
|
|
73
73
|
const insertsAvailable = Array.isArray(inserts) && inserts.length > 0;
|
74
74
|
const insertsFrequency =
|
75
75
|
insertsAvailable && inserts[0]?.frequency > 0 ? inserts[0].frequency : null;
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
|
77
|
+
const { propertiesInsertsMap, insertablePropertiesIDList } = useMemo(() => {
|
78
|
+
const propertiesLength = properties.length;
|
79
|
+
const validInserts = insertsAvailable
|
80
|
+
? inserts.filter(({ index }) => index >= 0 && index < propertiesLength)
|
79
81
|
: null;
|
82
|
+
if (validInserts) {
|
83
|
+
const propertiesInsertsMap = new Map();
|
84
|
+
for (const insert of validInserts) {
|
85
|
+
const property = properties[insert.index];
|
86
|
+
propertiesInsertsMap.set(property.property_id, insert);
|
87
|
+
};
|
88
|
+
const insertablePropertiesIDList = Array.from(propertiesInsertsMap.keys());
|
89
|
+
|
90
|
+
return { propertiesInsertsMap, insertablePropertiesIDList };
|
91
|
+
}
|
92
|
+
return {};
|
93
|
+
}, [properties]);
|
80
94
|
|
81
95
|
const items = propertiesByPage(properties, propertiesPagination).map((page, i) => (
|
82
96
|
<ConditionalWrapper
|
@@ -96,15 +110,18 @@ const PropertiesDisplay = ({
|
|
96
110
|
* TODO: Allow for multiple inserts
|
97
111
|
* This code only allows one insert from the inserts array to be show at a time
|
98
112
|
*/
|
99
|
-
if (insertsFrequency &&
|
113
|
+
if (insertsFrequency && index % insertsFrequency === 0 && index !== 0) {
|
100
114
|
return (
|
101
115
|
<React.Fragment key={property.property_id}>
|
102
116
|
{inserts[0].component}
|
103
117
|
<Item property={property} {...other} />
|
104
118
|
</React.Fragment>
|
105
119
|
);
|
106
|
-
} else if (
|
107
|
-
|
120
|
+
} else if (
|
121
|
+
insertablePropertiesIDList?.length &&
|
122
|
+
insertablePropertiesIDList.includes(property.property_id)
|
123
|
+
) {
|
124
|
+
const findResult = propertiesInsertsMap.get(property.property_id);
|
108
125
|
if (findResult) {
|
109
126
|
return (
|
110
127
|
<React.Fragment key={property.property_id}>
|
@@ -113,7 +130,7 @@ const PropertiesDisplay = ({
|
|
113
130
|
</React.Fragment>
|
114
131
|
);
|
115
132
|
}
|
116
|
-
}
|
133
|
+
}
|
117
134
|
|
118
135
|
return (
|
119
136
|
<Item
|