@stackedapp/utils 2.49.1 → 2.49.2
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.
- package/dist/conditions/handlers.js +18 -11
- package/package.json +1 -1
|
@@ -226,27 +226,34 @@ function evaluateStakedTokens(cond, ctx) {
|
|
|
226
226
|
return { isMet, details };
|
|
227
227
|
}
|
|
228
228
|
function evaluateLoginStreak(cond, ctx) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
const streakAtSurface = ctx.completionTrackers?.currentLoginStreak;
|
|
230
|
+
const currentStreak = ctx.snap.loginStreak || 0;
|
|
231
|
+
let isMet;
|
|
232
|
+
let displayAmount;
|
|
233
|
+
let displayGoal;
|
|
234
|
+
if (streakAtSurface != null) {
|
|
235
|
+
// Completion context: delta check, but display absolute values
|
|
236
|
+
const delta = currentStreak - streakAtSurface + 1;
|
|
237
|
+
isMet = delta >= cond.days;
|
|
238
|
+
displayAmount = currentStreak;
|
|
239
|
+
displayGoal = streakAtSurface + cond.days - 1;
|
|
233
240
|
}
|
|
234
241
|
else {
|
|
235
242
|
// Surfacing context: absolute streak
|
|
236
|
-
|
|
243
|
+
isMet = currentStreak >= cond.days;
|
|
244
|
+
displayAmount = currentStreak;
|
|
245
|
+
displayGoal = cond.days;
|
|
237
246
|
}
|
|
238
|
-
const trackerGoal = cond.days;
|
|
239
|
-
const isMet = trackerAmount >= trackerGoal;
|
|
240
247
|
return {
|
|
241
248
|
isMet,
|
|
242
249
|
details: [
|
|
243
250
|
{
|
|
244
251
|
isMet,
|
|
245
252
|
kind: 'loginStreak',
|
|
246
|
-
trackerAmount,
|
|
247
|
-
trackerGoal,
|
|
248
|
-
percentCompleted: (0, helpers_1.calculatePercent)(
|
|
249
|
-
text: templateText(cond, { current:
|
|
253
|
+
trackerAmount: displayAmount,
|
|
254
|
+
trackerGoal: displayGoal,
|
|
255
|
+
percentCompleted: (0, helpers_1.calculatePercent)(displayAmount, displayGoal, isMet),
|
|
256
|
+
text: templateText(cond, { current: displayAmount, goal: displayGoal }, `Login streak of ${displayGoal || 0} days`),
|
|
250
257
|
},
|
|
251
258
|
],
|
|
252
259
|
};
|