mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Don't display broken streak through the API
This commit is contained in:
parent
30559ba043
commit
86ffa7f0cc
1 changed files with 10 additions and 4 deletions
|
|
@ -70,12 +70,18 @@ async function renderAccount(
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|
||||||
let streakDays = 0;
|
let streakDays = 0;
|
||||||
const streakStart = event.author_stats?.streak_start;
|
let streakStart = event.author_stats?.streak_start ?? null;
|
||||||
const streakEnd = event.author_stats?.streak_end;
|
let streakEnd = event.author_stats?.streak_end ?? null;
|
||||||
|
|
||||||
if (streakStart && streakEnd) {
|
if (streakStart && streakEnd) {
|
||||||
const delta = streakEnd - streakStart;
|
const broken = nostrNow() - streakEnd > 86400;
|
||||||
streakDays = Math.max(Math.ceil(delta / 86400), 1);
|
if (broken) {
|
||||||
|
streakStart = null;
|
||||||
|
streakEnd = null;
|
||||||
|
} else {
|
||||||
|
const delta = streakEnd - streakStart;
|
||||||
|
streakDays = Math.max(Math.ceil(delta / 86400), 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue