Skip to content

Commit

Permalink
Fix issue where broken Google links prevent good Google lnks from app…
Browse files Browse the repository at this point in the history
…earing
  • Loading branch information
mapomatic committed Nov 11, 2024
1 parent 5ea1ad4 commit 16d5df6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions WME-Place-Harmonizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8098,7 +8098,7 @@ id="WMEPH-zipAltNameAdd"autocomplete="off" style="font-size:0.85em;width:65px;pa
);
venue.attributes.externalProviderIDs.forEach(link => {
const result = googleResults.find(r => r.uuid === link.attributes.uuid);
if (result) {
if (result && !result.brokenLink) {
const linkStyle = 'margin-left: 5px;text-decoration: none;color: cadetblue;';
let $nameSpan;
const $row = $('<div>', { class: 'banner-row', style: 'border-top: 1px solid #ccc;' }).append(
Expand Down Expand Up @@ -8193,12 +8193,12 @@ id="WMEPH-zipAltNameAdd"autocomplete="off" style="font-size:0.85em;width:65px;pa
const refreshInterval = 5 * 60 * 1000; // silently refresh data if it's over 5 minutes old
const staleLimit = 15 * 60 * 1000; // require new data if it's over 15 minutes old
if (_googleResults.hasOwnProperty(uuid)) {
const result = _googleResults[uuid];
let result = _googleResults[uuid];
const age = Date.now() - result.timestamp;
if (age < staleLimit) {
if (age > refreshInterval) {
// Refresh the data in the background.
fetchGooglePlace(uuid);
result = fetchGooglePlace(uuid);
}
return Promise.resolve(result);
}
Expand All @@ -8213,6 +8213,11 @@ id="WMEPH-zipAltNameAdd"autocomplete="off" style="font-size:0.85em;width:65px;pa
placeId: uuid,
fields: ['website', 'business_status', 'url', 'name', 'geometry']
}, googleResult => {
if (!googleResult) {
googleResult = {
brokenLink: true
};
}
googleResult.uuid = uuid;
googleResult.timestamp = Date.now();
_googleResults[uuid] = googleResult;
Expand Down Expand Up @@ -8306,8 +8311,8 @@ id="WMEPH-zipAltNameAdd"autocomplete="off" style="font-size:0.85em;width:65px;pa
timeoutDestroyGooglePlacePoint();
} else {
fetchGoogleLinkInfo(uuid).then(res => {
if (res.error || res.apiDisabled) {
// API was temporarily disabled. Ignore for now.
if (res.brokenLink || res.error || res.apiDisabled) {
// API was temporarily disabled or result was a broken uuid link. Ignore for now.
} else {
drawGooglePlacePoint(uuid);
}
Expand Down

0 comments on commit 16d5df6

Please sign in to comment.