mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 13:21:37 +02:00
Merge pull request #20371 from overleaf/mf-us-gov-banner
[web] Add US gov banner based on inclusion and exclusion criteria GitOrigin-RevId: c45ed280c8ef2dbdf9f3b84488e767c06fcc1ae1
This commit is contained in:
@@ -8,11 +8,26 @@ const POSTPONE_DURATION_MS = 24 * 60 * 60 * 1000 // 1 day
|
||||
* @param {string} userId
|
||||
* @param {string} tutorialKey
|
||||
* @param {'completed' | 'postponed'} state
|
||||
* @param {Date} [postponedUntil] - The date until which the tutorial is postponed
|
||||
*/
|
||||
async function setTutorialState(userId, tutorialKey, state) {
|
||||
async function setTutorialState(
|
||||
userId,
|
||||
tutorialKey,
|
||||
state,
|
||||
postponedUntil = null
|
||||
) {
|
||||
const updateData = {
|
||||
state,
|
||||
updatedAt: new Date(),
|
||||
}
|
||||
|
||||
if (state === 'postponed' && postponedUntil) {
|
||||
updateData.postponedUntil = postponedUntil
|
||||
}
|
||||
|
||||
await UserUpdater.promises.updateUser(userId, {
|
||||
$set: {
|
||||
[`completedTutorials.${tutorialKey}`]: { state, updatedAt: new Date() },
|
||||
[`completedTutorials.${tutorialKey}`]: updateData,
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -29,9 +44,11 @@ function getInactiveTutorials(user, tutorialKey) {
|
||||
// Legacy format: single date means the tutorial was completed
|
||||
inactiveTutorials.push(key)
|
||||
} else if (record.state === 'postponed') {
|
||||
const postponedUntil = new Date(
|
||||
const defaultPostponedUntil = new Date(
|
||||
record.updatedAt.getTime() + POSTPONE_DURATION_MS
|
||||
)
|
||||
|
||||
const postponedUntil = record.postponedUntil ?? defaultPostponedUntil
|
||||
if (new Date() < postponedUntil) {
|
||||
inactiveTutorials.push(key)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user