homeflowjs 0.12.13 → 0.12.15

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 lastSearch = JSON.parse(searchHistory)[0];
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].property_url;
35
- propertyLinks.prev = properties[index - 1].property_url;
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].property_url;
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].property_url;
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].property_url;
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].property_url;
101
+ propertyLinks.prev = getPropertyUrl(properties[properties.length - 1]);
89
102
  }
90
103
 
91
104
  return dispatch(setPropertyLinks(propertyLinks));
@@ -3,7 +3,7 @@ const initCookieConsent = () => {
3
3
  const defaultMessage = 'This website uses cookies to improve your experience.';
4
4
  // appends the 'decline' and 'learn more' links to the message
5
5
  const ccFullscreenMessage = (message = defaultMessage, href) => {
6
- let newMessage = `${message}<a aria-label="learn more about cookies" tabindex="0" class="cc-link" href="${href}" target="_blank">Learn more</a>`;
6
+ let newMessage = `${message}<a aria-label="learn more about cookies" tabindex="0" class="cc-link" href="${href}" target="_blank">View cookie policy</a>`;
7
7
  newMessage += ' or <a aria-label="deny cookies" role="button" tabindex="0" class="cc-btn cc-deny cc-deny-link">decline</a>';
8
8
  return newMessage;
9
9
  };
@@ -56,8 +56,8 @@ const initCookieConsent = () => {
56
56
  message: ccFullscreenMessage(message, href),
57
57
  },
58
58
  elements: {
59
- deny: '<a style="display: none;"></a>',
60
- link: '<a style="display: none;"></a>',
59
+ deny: '<a style="display: none;" href="#"></a>',
60
+ link: '<a style="display: none;" href="#"></a>',
61
61
  },
62
62
  };
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.12.13",
3
+ "version": "0.12.15",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",