Fix birthday bug being perpetually snoozed
This commit is contained in:
@@ -15,7 +15,10 @@ import debounce from 'lodash.debounce'
|
|||||||
import {networkRetry} from '#/lib/async/retry'
|
import {networkRetry} from '#/lib/async/retry'
|
||||||
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
|
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
|
||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
|
import {
|
||||||
|
hasSnoozedBirthdateUpdateForDid,
|
||||||
|
snoozeBirthdateUpdateAllowedForDid,
|
||||||
|
} from '#/state/birthdate'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import * as debug from '#/ageAssurance/debug'
|
import * as debug from '#/ageAssurance/debug'
|
||||||
import {logger} from '#/ageAssurance/logger'
|
import {logger} from '#/ageAssurance/logger'
|
||||||
@@ -331,10 +334,17 @@ export async function getOtherRequiredData({
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the user is under the minimum age, and the birthdate is not due to
|
* If the user is under the minimum age, and the birthdate is not due to the
|
||||||
* the legacy bug, snooze further birthdate updates for this user.
|
* legacy bug, AND we've not already snoozed their birthdate update, snooze
|
||||||
|
* further birthdate updates for this user.
|
||||||
|
*
|
||||||
|
* This is basically a migration step for this initial rollout.
|
||||||
*/
|
*/
|
||||||
if (data.birthdate && !isLegacyBirthdateBug(data.birthdate)) {
|
if (
|
||||||
|
data.birthdate &&
|
||||||
|
!isLegacyBirthdateBug(data.birthdate) &&
|
||||||
|
!hasSnoozedBirthdateUpdateForDid(did!)
|
||||||
|
) {
|
||||||
snoozeBirthdateUpdateAllowedForDid(did!)
|
snoozeBirthdateUpdateAllowedForDid(did!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,15 @@ export function snoozeBirthdateUpdateAllowedForDid(did: string) {
|
|||||||
account.set([did, 'birthdateLastUpdatedAt'], new Date().toISOString())
|
account.set([did, 'birthdateLastUpdatedAt'], new Date().toISOString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if we've already snoozed bday updates. In some cases, if one is
|
||||||
|
* present, we don't need to set another, such as in AA when reading initial
|
||||||
|
* data on load.
|
||||||
|
*/
|
||||||
|
export function hasSnoozedBirthdateUpdateForDid(did: string) {
|
||||||
|
return !!account.get([did, 'birthdateLastUpdatedAt'])
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether a birthdate update is currently allowed, based on the
|
* Returns whether a birthdate update is currently allowed, based on the
|
||||||
* last update timestamp stored locally.
|
* last update timestamp stored locally.
|
||||||
|
|||||||
Reference in New Issue
Block a user