homeflowjs 0.12.14 → 0.12.16
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.
@@ -14,7 +14,18 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
14
14
|
const searchHistory = localStorage.getItem('searchHistory');
|
15
15
|
if (!searchHistory) return null;
|
16
16
|
|
17
|
-
const
|
17
|
+
const parsedSearchHistory = JSON.parse(searchHistory);
|
18
|
+
if (!Array.isArray(parsedSearchHistory)) return null;
|
19
|
+
|
20
|
+
const validateSearch = (search) =>
|
21
|
+
(!search.isQuerySearch && search?.q)
|
22
|
+
|| search?.place
|
23
|
+
|| (search.isQuerySearch && search?.placeId)
|
24
|
+
|| (search.isQuerySearch && search?.poly);
|
25
|
+
|
26
|
+
const filteredSearchHistory = parsedSearchHistory.filter(validateSearch)
|
27
|
+
if (!filteredSearchHistory?.length) return null;
|
28
|
+
const lastSearch = filteredSearchHistory[0];
|
18
29
|
const { place, ...restOfSearch } = lastSearch;
|
19
30
|
const searchURL = `/search.ljson?${buildQueryString(restOfSearch)}`;
|
20
31
|
|
@@ -23,6 +34,8 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
23
34
|
prev: '',
|
24
35
|
};
|
25
36
|
|
37
|
+
const getPropertyUrl = (property) => property?.property_url || property?.url;
|
38
|
+
|
26
39
|
fetch(searchURL)
|
27
40
|
.then((response) => response.json())
|
28
41
|
.then(({ properties }) => {
|
@@ -31,8 +44,8 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
31
44
|
const index = properties.findIndex((prop) => prop.property_id === Homeflow.get('property').property_id);
|
32
45
|
// if there is a next and previous property in page, set those
|
33
46
|
if (properties[index + 1] && properties[index - 1]) {
|
34
|
-
propertyLinks.next = properties[index + 1]
|
35
|
-
propertyLinks.prev = properties[index - 1]
|
47
|
+
propertyLinks.next = getPropertyUrl(properties[index + 1]);
|
48
|
+
propertyLinks.prev = getPropertyUrl(properties[index - 1]);
|
36
49
|
|
37
50
|
return dispatch(setPropertyLinks(propertyLinks));
|
38
51
|
}
|
@@ -40,7 +53,7 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
40
53
|
// if there is no next but there is a previous, conduct search for next page
|
41
54
|
// but use previous
|
42
55
|
if (!properties[index + 1] && properties[index - 1]) {
|
43
|
-
propertyLinks.prev = properties[index - 1]
|
56
|
+
propertyLinks.prev = getPropertyUrl(properties[index - 1]);
|
44
57
|
|
45
58
|
const nextSearch = {
|
46
59
|
...restOfSearch,
|
@@ -54,7 +67,7 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
54
67
|
if (!properties) {
|
55
68
|
propertyLinks.next = '';
|
56
69
|
} else {
|
57
|
-
propertyLinks.next = properties[0]
|
70
|
+
propertyLinks.next = getPropertyUrl(properties[0]);
|
58
71
|
}
|
59
72
|
|
60
73
|
return dispatch(setPropertyLinks(propertyLinks));
|
@@ -64,7 +77,7 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
64
77
|
// if there is no previous but there is a next, conduct search for previous page
|
65
78
|
// but use next
|
66
79
|
if (!properties[index - 1] && properties[index + 1]) {
|
67
|
-
propertyLinks.next = properties[index + 1]
|
80
|
+
propertyLinks.next = getPropertyUrl(properties[index + 1]);
|
68
81
|
|
69
82
|
const nextSearch = {
|
70
83
|
...restOfSearch,
|
@@ -85,7 +98,7 @@ export const setPropertyLinksAsync = () => (dispatch) => {
|
|
85
98
|
if (!properties) {
|
86
99
|
propertyLinks.prev = '';
|
87
100
|
} else {
|
88
|
-
propertyLinks.prev = properties[properties.length - 1]
|
101
|
+
propertyLinks.prev = getPropertyUrl(properties[properties.length - 1]);
|
89
102
|
}
|
90
103
|
|
91
104
|
return dispatch(setPropertyLinks(propertyLinks));
|
package/app/hf-initialize.jsx
CHANGED
@@ -105,10 +105,13 @@ const hfInitialize = () => {
|
|
105
105
|
store.dispatch(setArticles(Homeflow.get('articles')));
|
106
106
|
}
|
107
107
|
|
108
|
+
// all property results routes
|
108
109
|
if (pageRoute === 'properties#index'
|
109
110
|
|| pageRoute === 'counties#show'
|
110
111
|
|| pageRoute === 'postcodes#show'
|
111
112
|
|| pageRoute === 'locations#show'
|
113
|
+
|| pageRoute === 'countries#show'
|
114
|
+
|| pageRoute === 'branches#properties'
|
112
115
|
) {
|
113
116
|
const searchFromFragment = parseFragment(window.location.pathname);
|
114
117
|
const defaultStatus = store.getState().app.themePreferences.default_search_status;
|