Skip to content

Commit

Permalink
Drop obsolete parameter updateLastSession
Browse files Browse the repository at this point in the history
Sessions are now always processed in chronological order.
  • Loading branch information
qsantos committed Jan 25, 2025
1 parent c5a644d commit 1a8d7c5
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -1372,14 +1372,11 @@ function saveStats() {
/** Increase a stat by a given amount
* @param {import("./types").Stat} stat - The stat to be increased
* @param {number} amount - The amount by which the stat should be increased
* @param {boolean} updateLastSession - Whether the last session should be updated
* @param {Date} now - The current time
*/
function updateStat(stat, amount, updateLastSession, now) {
function updateStat(stat, amount, now) {
stat.total += amount;
if (updateLastSession) {
stat.lastSession = amount;
}
stat.lastSession = amount;
stat.currentDay += amount;
if (stat.currentDay > stat.bestDay) {
stat.bestDay = stat.currentDay;
Expand All @@ -1394,14 +1391,11 @@ function updateStat(stat, amount, updateLastSession, now) {
function updateStats(session) {
const now = new Date(session.started);
detectNewDay(now);
const updateLastSession = session.started > stats.lastSessionStarted;
if (updateLastSession) {
stats.lastSessionStarted = session.started;
}
updateStat(stats.elapsed, session.elapsed, updateLastSession, now);
updateStat(stats.copiedCharacters, session.copiedCharacters, updateLastSession, now);
updateStat(stats.copiedGroups, session.copiedGroups, updateLastSession, now);
updateStat(stats.score, session.score, updateLastSession, now);
stats.lastSessionStarted = session.started;
updateStat(stats.elapsed, session.elapsed, now);
updateStat(stats.copiedCharacters, session.copiedCharacters, now);
updateStat(stats.copiedGroups, session.copiedGroups, now);
updateStat(stats.score, session.score, now);
}

/** Compute the duration of a character with the current settings
Expand Down

0 comments on commit 1a8d7c5

Please sign in to comment.