homeflowjs 0.12.19 → 0.12.20
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.
@@ -151,6 +151,28 @@ export const loadNext = () => (dispatch, getState) => {
|
|
151
151
|
});
|
152
152
|
};
|
153
153
|
|
154
|
+
export const loadPage = (payload) => (dispatch, getState) => {
|
155
|
+
dispatch(setLoading({ properties: true }));
|
156
|
+
// set page on search to page + 1
|
157
|
+
let newProperties = [...getState().properties.properties];
|
158
|
+
const newSearch = { ...getState().search.currentSearch };
|
159
|
+
newSearch.page = payload;
|
160
|
+
// conduct search ljson
|
161
|
+
return fetch(`/search.ljson?${buildQueryString(newSearch)}`)
|
162
|
+
.then((response) => response.json())
|
163
|
+
.then((json) => {
|
164
|
+
if (json.properties) {
|
165
|
+
// add the page number to each new property for dividing properties into per-page divs
|
166
|
+
const addedProperties = json.properties.map((property) => (
|
167
|
+
{ ...property, resultPage: newSearch.page }
|
168
|
+
));
|
169
|
+
newProperties = [...addedProperties, ...newProperties];
|
170
|
+
dispatch(setProperties(newProperties));
|
171
|
+
dispatch(setLoading({ properties: false }));
|
172
|
+
}
|
173
|
+
});
|
174
|
+
};
|
175
|
+
|
154
176
|
export const toggleSavedProperty = (payload) => ({
|
155
177
|
type: PropertiesActionTypes.TOGGLE_SAVED_PROPERTY,
|
156
178
|
payload,
|