abmp-npm 2.0.79 → 2.0.80

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": "abmp-npm",
3
- "version": "2.0.79",
3
+ "version": "2.0.80",
4
4
  "main": "index.js",
5
5
  "files": [
6
6
  "index.js",
package/pages/Home.js CHANGED
@@ -3,12 +3,12 @@ const { location: wixLocation } = require('@wix/site-location');
3
3
  const { window: wixWindow, rendering } = require('@wix/site-window');
4
4
  const { withWarmUpData } = require('psdev-utils/frontend');
5
5
 
6
- const { ADDRESS_STATUS_TYPES, DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
6
+ const { DEFAULT_FILTER, DROPDOWN_OPTIONS } = require('../public/consts.js');
7
7
  const { createHomepageUtils } = require('../public/Utils/homePage.js');
8
8
  const {
9
9
  getMainAddress,
10
+ findMainAddress,
10
11
  formatPracticeAreasForDisplay,
11
- checkAddressIsVisible,
12
12
  isWixHostedImage,
13
13
  normalizeExternalUrl,
14
14
  buildMapLink,
@@ -226,25 +226,24 @@ const homePageOnReady = async ({
226
226
  $item('#milesAwayText').text = '';
227
227
  }
228
228
 
229
- // 7) "Show maps" button shown only when we can actually build a link for it
230
- const visible = checkAddressIsVisible(addresses);
231
- const fullAddressWithValidCoords = visible.find(
232
- addr =>
233
- addr.addressStatus === ADDRESS_STATUS_TYPES.FULL_ADDRESS &&
234
- addr.latitude &&
235
- addr.longitude
236
- );
237
-
238
- // Links to the street address rather than the stored coordinates, which are
239
- // unreliable for some members. The full-address filter above is what keeps
240
- // this safe: members set to state_city_zip or dont_show never reach here, so
241
- // a hidden street address is never put in a maps URL.
229
+ // 7) "Show maps" button - directions to whatever address the member displays.
230
+ //
231
+ // Uses the same address as the location text above, so the button always
232
+ // matches what the member is showing. Members displaying city/state/ZIP get
233
+ // directions to that, rather than no button at all: their NetForum
234
+ // coordinates can be miles off (see Monday 12596102059), and the text they
235
+ // publish is the reliable value.
236
+ //
237
+ // Privacy is enforced in buildMapLink, not here - it delegates to
238
+ // formatAddress, which prints the street line only for full_address, and
239
+ // returns '' outright for dont_show. findMainAddress also excludes
240
+ // dont_show. A hidden street address can never reach a maps URL.
242
241
  //
243
- // Gate on the link rather than on the address. buildMapLink returns '' when
244
- // it can build neither an address nor a coordinate link, and it also handles
245
- // being passed undefined - so this cannot leave a visible button linking
246
- // nowhere, even if the filter above is later relaxed.
247
- const mapLink = buildMapLink(fullAddressWithValidCoords);
242
+ // Gate on the link rather than the address: buildMapLink returns '' when it
243
+ // can build neither an address nor a coordinate link, and handles being
244
+ // passed '' or undefined, so the button is never shown linking nowhere.
245
+ const mapAddress = findMainAddress(itemData.addressDisplayOption, addresses);
246
+ const mapLink = buildMapLink(mapAddress);
248
247
 
249
248
  if (mapLink) {
250
249
  $item('#showMaps').enable();
@@ -137,6 +137,12 @@ function formatAddress(item) {
137
137
  function buildMapLink(address) {
138
138
  if (!address) return '';
139
139
 
140
+ // A member set to dont_show has opted out of publishing their location at all.
141
+ // formatAddress returns '' for them, so without this guard they would fall
142
+ // through to the coordinate fallback below and have their exact position put
143
+ // into an outbound maps URL - worse than the street line they chose to hide.
144
+ if (address.addressStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) return '';
145
+
140
146
  const query = formatAddress(address);
141
147
  if (query) {
142
148
  return `https://maps.google.com/?q=${encodeURIComponent(query)}`;