Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 5f5c39e

Browse files
committed
improved calendar parsers
1 parent 92be7c1 commit 5f5c39e

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

src/components/NavBar.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,19 @@ export function NavBar(navBarProps: NavBarProps) {
2323
);
2424

2525
const updateBar = () => {
26+
if (!view.plugin.statusBarItem) {
27+
view.plugin.statusBarItem = view.plugin.addStatusBarItem();
28+
}
2629
view.plugin.statusBarItem.replaceChildren();
2730
view.plugin.statusBarItem.createEl("span", {
2831
text: `${table.getFilteredRowModel().rows.length}/${view.rows.length} '${
2932
view.diskConfig.yaml.name
3033
}'`,
3134
});
3235
};
33-
// Control
36+
37+
// Bar status control
3438
useEffect(() => {
35-
if (!view.plugin.statusBarItem) {
36-
view.plugin.statusBarItem = view.plugin.addStatusBarItem();
37-
}
3839
updateBar();
3940
}, [table.getFilteredRowModel().rows.length]);
4041

src/main.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,12 @@ export default class DBFolderPlugin extends Plugin {
429429
*/
430430
this.registerEvent(app.workspace.on("active-leaf-change", () => {
431431
const activeView = app.workspace.getActiveViewOfType(DatabaseView);
432-
if (!activeView) {
432+
if (!activeView && this.statusBarItem) {
433433
this.statusBarItem.detach();
434434
this.statusBarItem = null;
435435
}
436-
else if (this.statusBarItem) {
436+
else if (activeView && this.statusBarItem) {
437437
activeView.handleUpdateStatusBar();
438-
} else {
439-
this.statusBarItem = this.addStatusBarItem();
440438
}
441439
}));
442440
}
@@ -529,7 +527,6 @@ export default class DBFolderPlugin extends Plugin {
529527

530528
// Ribbon Icon
531529
this.showRibbonIcon();
532-
533530
}
534531

535532
showRibbonIcon() {

src/services/parseServiceHelpers/MarkdownParser.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { parseLuxonDatetimeToString, parseLuxonDateToString } from "helpers/Luxo
33
import { Literal, WrappedLiteral } from "obsidian-dataview";
44
import { DataviewService } from "services/DataviewService";
55
import { DateTime } from "luxon";
6-
import { InputType, MarkdownBreakerRules } from "helpers/Constants";
6+
import { DEFAULT_SETTINGS, MarkdownBreakerRules } from "helpers/Constants";
77
import stringifyReplacer from "./StringifyReplacer";
88

99
class MarkdownParser extends TypeParser<Literal> {
@@ -41,10 +41,16 @@ class MarkdownParser extends TypeParser<Literal> {
4141
if (wrapped.value.hour === 0 && wrapped.value.minute === 0 && wrapped.value.second === 0) {
4242
// Parse date
4343

44-
auxMarkdown = parseLuxonDatetimeToString(wrapped.value, this.config.date_format);
44+
auxMarkdown = parseLuxonDatetimeToString(
45+
wrapped.value,
46+
this.config.date_format ?? DEFAULT_SETTINGS.local_settings.date_format
47+
);
4548
} else {
4649
// Parse datetime
47-
auxMarkdown = parseLuxonDateToString(wrapped.value, this.config.datetime_format);
50+
auxMarkdown = parseLuxonDateToString(
51+
wrapped.value,
52+
this.config.datetime_format ?? DEFAULT_SETTINGS.local_settings.datetime_format
53+
);
4854
}
4955
break;
5056
case 'object':

src/services/parseServiceHelpers/ParseBuilder.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LocalSettings } from "cdm/SettingsModel"
2-
import { InputType } from "helpers/Constants"
2+
import { DEFAULT_SETTINGS, InputType } from "helpers/Constants"
33
import ArrayParser from "./ArrayParser"
44
import BooleanParser from "./BooleanParser"
55
import CalendarParser from "./CalendarParser"
@@ -16,15 +16,17 @@ class ParseBuilder {
1616
static setType = (type: string, config: LocalSettings, isInline: boolean, wrapQuotes: boolean) => {
1717
switch (type) {
1818
case InputType.MARKDOWN:
19-
return new MarkdownParser().beforeParse(wrapQuotes, isInline);
19+
return new MarkdownParser()
20+
.setConfig(config)
21+
.beforeParse(wrapQuotes, isInline);
2022
case InputType.SORTING:
2123
return new SortingParser();
2224
case InputType.TAGS:
2325
return new ArrayParser();
2426
case InputType.CALENDAR:
25-
return new CalendarParser().beforeParse(config.date_format);
27+
return new CalendarParser().beforeParse(config.date_format ?? DEFAULT_SETTINGS.local_settings.date_format);
2628
case InputType.CALENDAR_TIME:
27-
return new CalendarParser().beforeParse(config.datetime_format);
29+
return new CalendarParser().beforeParse(config.datetime_format ?? DEFAULT_SETTINGS.local_settings.datetime_format);
2830
case InputType.METATADA_TIME:
2931
return new DatetimeISOParser()
3032
case InputType.NUMBER:

0 commit comments

Comments
 (0)