Skip to content

Commit

Permalink
track word count after meeting goal (#234)
Browse files Browse the repository at this point in the history
* Added issue #222
Word count continues to count up after reaching goal. Also added setting to optionally disable behaviour.

* removed extra space in formatting

* more concise description of setting

* actually saves setting

* setting removed

* format

---------

Co-authored-by: MadCatMagic <[email protected]>
  • Loading branch information
kevboh and MadCatMagic authored Jan 22, 2024
1 parent 19b38c1 commit 17ed844
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/view/explorer/ProjectDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
let goalPercentage: number;
let goalDescription: string;
$: {
goalPercentage = Math.ceil($goalProgress * 100);
goalDescription = `${$goalProgress * $pluginSettings.sessionGoal}/${
$pluginSettings.sessionGoal
}`;
goalPercentage = Math.ceil(Math.min($goalProgress, 1) * 100);
goalDescription = `${Math.round(
$goalProgress * $pluginSettings.sessionGoal
)}/${$pluginSettings.sessionGoal}`;
}
function pluralize(
Expand Down
6 changes: 3 additions & 3 deletions src/view/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ export const goalProgress = derived(
const goal = $pluginSettings.sessionGoal;

if ($pluginSettings.applyGoalTo === "all") {
return Math.min(latestSession.total / goal, 1);
return latestSession.total / goal;
} else if ($pluginSettings.applyGoalTo === "project") {
const draftTotal = latestSession.drafts[$selectedDraft.vaultPath];
if (draftTotal) {
return Math.min(draftTotal.total / goal, 1);
return draftTotal.total / goal;
} else {
return 0;
}
Expand All @@ -88,7 +88,7 @@ export const goalProgress = derived(
return draftTotals.total;
} else {
const sceneTotal = draftTotals.scenes[name] ?? 0;
return Math.min(sceneTotal / goal, 1);
return sceneTotal / goal;
}
}
}
Expand Down

0 comments on commit 17ed844

Please sign in to comment.