Skip to content

Commit c911581

Browse files
committed
fix: improve entry date handling and adjust lastCheckInTime initialization
1 parent a526e46 commit c911581

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

daily-overview.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ export const computeDailyOverview = (entries: Entry[]): DailyOverview => {
2727

2828
for (const entry of entries ?? []) {
2929
let raw: string | Date = '';
30-
if (entry?.date !== undefined) raw = entry.date!;
31-
else if (entry?.day !== undefined) raw = entry.day!;
32-
else if (entry?.key !== undefined) raw = entry.key!;
30+
if (entry?.date !== undefined) raw = entry.date;
31+
else if (entry?.day !== undefined) raw = entry.day;
32+
else if (entry?.key !== undefined) raw = entry.key;
3333
else if (typeof entry === 'string' || entry instanceof Date) raw = entry as string | Date;
34+
3435
const key = normalizeDateKey(raw);
3536
if (!key) continue;
37+
3638
dates.add(key);
3739
if (!earliestKey || key < earliestKey) {
3840
earliestKey = key;
@@ -45,7 +47,7 @@ export const computeDailyOverview = (entries: Entry[]): DailyOverview => {
4547

4648
let streak = 0;
4749
if (hasEntries) {
48-
let cursor = new Date();
50+
const cursor = new Date();
4951
if (!hasToday) {
5052
cursor.setDate(cursor.getDate() - 1);
5153
}

main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class EasyTrackerPlugin extends Plugin {
1010
private overviewBlocks: HTMLElement[] = [];
1111
private locale: LocaleCode = 'en';
1212
private translator: Translator = createTranslator('en');
13-
private lastCheckInTime: number = 0;
13+
private lastCheckInTime = 0;
1414

1515
public t(key: LocaleKey, vars?: Record<string, string | number>): string {
1616
return this.translator(key, vars);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"scripts": {
99
"dev": "node esbuild.config.mjs",
1010
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
11-
"version": "node version-bump.mjs && git add manifest.json versions.json"
11+
"version": "node version-bump.mjs && git add manifest.json versions.json",
12+
"lint": "eslint . --ext .ts"
1213
},
1314
"keywords": ["obsidian", "plugin", "tracker", "habit", "check-in", "log"],
1415
"license": "MIT",

0 commit comments

Comments
 (0)