abmp-npm 2.0.54 → 2.0.55
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.
|
@@ -148,7 +148,9 @@ function buildMembersSearchQuery(data) {
|
|
|
148
148
|
latitude: filter.latitude,
|
|
149
149
|
longitude: filter.longitude,
|
|
150
150
|
},
|
|
151
|
-
findMainAddress(item.addressDisplayOption, item.addresses
|
|
151
|
+
findMainAddress(item.addressDisplayOption, item.addresses, {
|
|
152
|
+
requireValidCoordinates: true,
|
|
153
|
+
})
|
|
152
154
|
),
|
|
153
155
|
}));
|
|
154
156
|
const resultWithDistances = {
|
|
@@ -16,7 +16,8 @@ async function ensureUniqueUrlsInBatch(memberDataList) {
|
|
|
16
16
|
return memberDataList;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// Group members by their normalized base URL
|
|
19
|
+
// Group members by their normalized base URL (case-insensitive to avoid
|
|
20
|
+
// "John-12" and "john-12" being treated as different when slugs are matched case-insensitively)
|
|
20
21
|
const urlGroups = new Map();
|
|
21
22
|
|
|
22
23
|
memberDataList.forEach(member => {
|
|
@@ -24,16 +25,17 @@ async function ensureUniqueUrlsInBatch(memberDataList) {
|
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
// Extract the base URL (without any counter) for grouping
|
|
28
28
|
const baseUrl = extractBaseUrl(member.url);
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const groupKey = baseUrl.toLowerCase();
|
|
30
|
+
if (!urlGroups.has(groupKey)) {
|
|
31
|
+
urlGroups.set(groupKey, []);
|
|
31
32
|
}
|
|
32
|
-
urlGroups.get(
|
|
33
|
+
urlGroups.get(groupKey).push(member);
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
// For each group, check database and assign unique URLs sequentially
|
|
36
|
-
for (const [
|
|
37
|
+
for (const [groupKey, members] of urlGroups.entries()) {
|
|
38
|
+
const baseUrl = groupKey; // lowercase for consistent slug assignment
|
|
37
39
|
if (members.length <= 1) {
|
|
38
40
|
// Single member - still check DB to ensure it doesn't conflict with other pages
|
|
39
41
|
const member = members[0];
|
package/package.json
CHANGED
|
@@ -66,20 +66,31 @@ function debouncedFunction({ func, debounceTimeout, timeoutType, args }) {
|
|
|
66
66
|
|
|
67
67
|
const isValidLocation = location => location.latitude && location.longitude;
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
/**
|
|
70
|
+
* @param {Array} addressDisplayOption
|
|
71
|
+
* @param {Array} addresses
|
|
72
|
+
* @param {Object|boolean} [options] - Optional. Pass { requireValidCoordinates: true } for home search/distance; omit or false for profile display.
|
|
73
|
+
*/
|
|
74
|
+
function findMainAddress(addressDisplayOption = [], addresses = [], options = {}) {
|
|
75
|
+
const requireValidCoordinates =
|
|
76
|
+
typeof options === 'boolean' ? options : Boolean(options?.requireValidCoordinates);
|
|
77
|
+
const optionsArr = Array.isArray(addressDisplayOption) ? addressDisplayOption : [];
|
|
78
|
+
const mainOpt = optionsArr.find(opt => opt.isMain);
|
|
72
79
|
if (mainOpt) {
|
|
73
80
|
const mainAddr = addresses.find(
|
|
74
|
-
addr =>
|
|
81
|
+
addr =>
|
|
82
|
+
addr.key === mainOpt.key &&
|
|
83
|
+
addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW &&
|
|
84
|
+
(!requireValidCoordinates || isValidLocation(addr))
|
|
75
85
|
);
|
|
76
|
-
if (mainAddr
|
|
86
|
+
if (mainAddr) {
|
|
77
87
|
return mainAddr;
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
|
-
// 2) fallback: if there is any visible address, use it
|
|
81
90
|
const visibleAddresses = addresses.filter(
|
|
82
|
-
addr =>
|
|
91
|
+
addr =>
|
|
92
|
+
addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW &&
|
|
93
|
+
(!requireValidCoordinates || isValidLocation(addr))
|
|
83
94
|
);
|
|
84
95
|
if (visibleAddresses.length) {
|
|
85
96
|
return visibleAddresses[0];
|
|
@@ -107,8 +118,13 @@ function formatAddress(item) {
|
|
|
107
118
|
return addressParts.filter(Boolean).join(', ');
|
|
108
119
|
}
|
|
109
120
|
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
/**
|
|
122
|
+
* @param {Array} addressDisplayOption
|
|
123
|
+
* @param {Array} addresses
|
|
124
|
+
* @param {Object|boolean} [options] - Optional. Pass { requireValidCoordinates: true } for home search/distance; omit or false for profile display.
|
|
125
|
+
*/
|
|
126
|
+
function getMainAddress(addressDisplayOption = [], addresses = [], options = {}) {
|
|
127
|
+
const mainAddr = findMainAddress(addressDisplayOption, addresses, options);
|
|
112
128
|
if (mainAddr) {
|
|
113
129
|
return formatAddress(mainAddr);
|
|
114
130
|
}
|