fix: show membership date for stores without pickups
Treat Foodsharing's zero lastFetch value as no pickup, store memberSince, and show compact, visible mobile status information without hover tooltips.
This commit is contained in:
@@ -25,16 +25,23 @@ function getStaleLastPickupStoreIds(config = [], now = Date.now()) {
|
||||
|
||||
function parseLastFetchTimestamp(value) {
|
||||
if (typeof value === 'string') {
|
||||
return parseTimestamp(value);
|
||||
if (value.trim() !== '' && Number.isFinite(Number(value))) {
|
||||
return parseLastFetchTimestamp(Number(value));
|
||||
}
|
||||
const timestamp = parseTimestamp(value);
|
||||
return timestamp && timestamp > 0 ? timestamp : null;
|
||||
}
|
||||
if (!Number.isFinite(Number(value))) {
|
||||
return null;
|
||||
}
|
||||
const numericValue = Number(value);
|
||||
if (numericValue <= 0) {
|
||||
return null;
|
||||
}
|
||||
return numericValue > 1e12 ? numericValue : numericValue * 1000;
|
||||
}
|
||||
|
||||
function updateLastPickupInfo(entry, lastFetchValue, checkedAt = new Date()) {
|
||||
function updateLastPickupInfo(entry, lastFetchValue, memberSinceValue, checkedAt = new Date()) {
|
||||
if (!entry || typeof entry !== 'object') {
|
||||
return false;
|
||||
}
|
||||
@@ -51,6 +58,17 @@ function updateLastPickupInfo(entry, lastFetchValue, checkedAt = new Date()) {
|
||||
entry.lastPickupAt = lastPickupAt;
|
||||
changed = true;
|
||||
}
|
||||
} else if (entry.lastPickupAt) {
|
||||
delete entry.lastPickupAt;
|
||||
changed = true;
|
||||
}
|
||||
const memberSinceTimestamp = parseTimestamp(memberSinceValue);
|
||||
if (memberSinceTimestamp !== null && memberSinceTimestamp > 0) {
|
||||
const memberSinceAt = new Date(memberSinceTimestamp).toISOString();
|
||||
if (entry.memberSinceAt !== memberSinceAt) {
|
||||
entry.memberSinceAt = memberSinceAt;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
@@ -1515,7 +1515,8 @@ async function checkDormantMembers(sessionId, options = {}) {
|
||||
const lastFetchRaw = memberEntry.lastFetch ?? memberEntry.last_fetch ?? null;
|
||||
const lastFetchMs = parseLastFetchTimestamp(lastFetchRaw);
|
||||
const configEntry = configEntryMap.get(storeId)?.entry;
|
||||
if (updateLastPickupInfo(configEntry, lastFetchRaw)) {
|
||||
const memberSinceRaw = memberEntry.memberSince ?? memberEntry.member_since ?? null;
|
||||
if (updateLastPickupInfo(configEntry, lastFetchRaw, memberSinceRaw)) {
|
||||
configChanged = true;
|
||||
}
|
||||
if (sendWarnings && !skipMap.get(storeId) && (!lastFetchMs || lastFetchMs < fourMonthsAgo)) {
|
||||
|
||||
Reference in New Issue
Block a user