Skip to content

Commit 38f8c82

Browse files
authored
Merge pull request #383 from decaf-dev/dev
Fix build errors
2 parents 9bbff4d + f73d6b4 commit 38f8c82

File tree

6 files changed

+37
-27
lines changed

6 files changed

+37
-27
lines changed
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
import { Modal } from "obsidian";
2-
import CustomFilterApp from "../svelte/custom-filter-app/index.svelte";
32
import VaultExplorerPlugin from "src/main";
3+
import { mount, unmount } from "svelte";
4+
import CustomFilterApp from "../svelte/custom-filter-app/index.svelte";
45

56
export default class CustomFilterModal extends Modal {
6-
component: CustomFilterApp | null;
7+
customFilterApp: ReturnType<typeof mount> | null;
78
plugin: VaultExplorerPlugin;
89

910
constructor(plugin: VaultExplorerPlugin) {
1011
super(plugin.app);
1112
this.plugin = plugin;
12-
this.component = null;
13+
this.customFilterApp = null;
1314
}
1415

1516
onOpen(): void {
1617
const { contentEl } = this;
1718

18-
this.component = new CustomFilterApp({
19+
this.customFilterApp = mount(CustomFilterApp, {
1920
target: contentEl
2021
});
2122
}
2223

2324
onClose(): void {
2425
const { contentEl } = this;
25-
this.component?.$destroy();
26+
27+
if (this.customFilterApp) {
28+
unmount(this.customFilterApp);
29+
}
30+
2631
contentEl.empty();
2732
}
2833
}

src/obsidian/vault-explorer-settings-tab.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ import { TExplorerView } from "src/types";
2626
import ImageSourceApp from "../svelte/image-source-app/index.svelte";
2727

2828
import { clearSMICache } from "src/svelte/app/services/smi-cache";
29+
import { mount, unmount } from "svelte";
2930

3031
export default class VaultExplorerSettingsTab extends PluginSettingTab {
3132
plugin: VaultExplorerPlugin;
3233

33-
imageSourceApp: ImageSourceApp | null;
34+
imageSourceApp: ReturnType<typeof mount> | null;
3435

3536
constructor(app: App, plugin: VaultExplorerPlugin) {
3637
super(app, plugin);
@@ -230,7 +231,7 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
230231

231232
new Setting(containerEl).setName("Grid view").setHeading();
232233

233-
this.imageSourceApp = new ImageSourceApp({
234+
this.imageSourceApp = mount(ImageSourceApp, {
234235
target: containerEl
235236
});
236237

@@ -683,7 +684,9 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
683684
}
684685

685686
onClose() {
686-
this.imageSourceApp?.$destroy();
687+
if (this.imageSourceApp) {
688+
unmount(this.imageSourceApp);
689+
}
687690
}
688691

689692
private updateViewOrder(

src/obsidian/vault-explorer-view.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { ItemView, WorkspaceLeaf } from "obsidian";
22

33
import { VAULT_EXPLORER_VIEW } from "src/constants";
4-
import VaultExplorerApp from "../svelte/app/index.svelte";
5-
import VaultExplorerPlugin from "src/main";
64
import EventManager from "src/event/event-manager";
75
import { PluginEvent } from "src/event/types";
6+
import VaultExplorerPlugin from "src/main";
7+
import { mount, unmount } from "svelte";
8+
import VaultExplorerApp from "../svelte/app/index.svelte";
89

910
export default class VaultExplorerView extends ItemView {
10-
component: VaultExplorerApp | null;
11+
vaultExplorerApp: ReturnType<typeof mount> | null;
1112
plugin: VaultExplorerPlugin;
1213

1314
constructor(leaf: WorkspaceLeaf, plugin: VaultExplorerPlugin) {
1415
super(leaf);
15-
this.component = null;
16+
this.vaultExplorerApp = null;
1617
this.plugin = plugin;
1718
this.navigation = true;
1819
}
@@ -43,12 +44,14 @@ export default class VaultExplorerView extends ItemView {
4344

4445
const containerEl = this.containerEl.children[1];
4546

46-
this.component = new VaultExplorerApp({
47+
this.vaultExplorerApp = mount(VaultExplorerApp, {
4748
target: containerEl
4849
});
4950
}
5051

5152
async onClose() {
52-
this.component?.$destroy();
53+
if (this.vaultExplorerApp) {
54+
unmount(this.vaultExplorerApp);
55+
}
5356
}
5457
}

src/svelte/app/services/time-string.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { moment } from "obsidian";
22

33
export const formatAsBearTimeString = (milliseconds: number) => {
4-
const now = moment.default();
5-
const time = moment.default(milliseconds);
4+
const now = (moment as any)();
5+
const time = (moment as any)(milliseconds);
66

77
const diffInSeconds = now.diff(time, "seconds");
88
const diffInMinutes = now.diff(time, "minutes");

src/svelte/shared/components/tab.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@
104104
background-color: var(--background-modifier-hover);
105105
}
106106
</style>
107-
``

src/svelte/shared/services/time-utils.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const DATE_FORMATS = ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DDTHH:mm", "YYYY-MM-DD"];
77
* @returns - The current time in milliseconds
88
*/
99
export const getStartOfTodayMillis = () => {
10-
return moment.default().startOf("day").valueOf();
10+
return (moment as any)().startOf("day").valueOf();
1111
};
1212

1313
/**
@@ -16,27 +16,27 @@ export const getStartOfTodayMillis = () => {
1616
* @returns - The start of the day in milliseconds
1717
*/
1818
export const getStartOfDayMillis = (date: string) => {
19-
return moment.default(date).startOf("day").valueOf();
19+
return (moment as any)(date).startOf("day").valueOf();
2020
};
2121

2222
/**
2323
* Gets 12:00 AM of the current week in milliseconds. The week starts on Sunday.
2424
* @returns - The start of the week in milliseconds
2525
*/
2626
export const getStartOfThisWeekMillis = () => {
27-
return moment.default().startOf("week").valueOf();
27+
return (moment as any)().startOf("week").valueOf();
2828
};
2929

3030
export const getMomentDate = (date: string) => {
31-
return moment.default(date, DATE_FORMATS, true);
31+
return (moment as any)(date, DATE_FORMATS, true);
3232
};
3333

3434
export const getDateDaysAgo = (daysAgo: number) => {
35-
return moment.default().subtract(daysAgo, "days").format("YYYY-MM-DD");
35+
return (moment as any)().subtract(daysAgo, "days").format("YYYY-MM-DD");
3636
};
3737

3838
export const getDateDaysAhead = (daysAgo: number) => {
39-
return moment.default().add(daysAgo, "days").format("YYYY-MM-DD");
39+
return (moment as any)().add(daysAgo, "days").format("YYYY-MM-DD");
4040
};
4141

4242
/**
@@ -45,7 +45,7 @@ export const getDateDaysAhead = (daysAgo: number) => {
4545
*/
4646
export const getStartOfLastWeekMillis = () => {
4747
//This is the Sunday the previous week
48-
return moment.default().subtract(1, "weeks").startOf("week").valueOf();
48+
return (moment as any)().subtract(1, "weeks").startOf("week").valueOf();
4949
};
5050

5151
/**
@@ -54,7 +54,7 @@ export const getStartOfLastWeekMillis = () => {
5454
* @returns - The date in milliseconds
5555
*/
5656
export const getTimeMillis = (date: string) => {
57-
const momentDate = moment.default(date, DATE_FORMATS, true);
57+
const momentDate = (moment as any)()(date, DATE_FORMATS, true);
5858

5959
if (!momentDate.isValid()) {
6060
throw new Error(`Date format not handled: ${date}`);
@@ -68,7 +68,7 @@ export const getTimeMillis = (date: string) => {
6868
* @returns - True if the date is supported, false otherwise
6969
*/
7070
export const isDateSupported = (date: string) => {
71-
const momentDate = moment.default(date, DATE_FORMATS, true);
71+
const momentDate = (moment as any)()(date, DATE_FORMATS, true);
7272
return momentDate.isValid();
7373
};
7474

@@ -78,7 +78,7 @@ export const isDateSupported = (date: string) => {
7878
* @returns - The end of the day in milliseconds
7979
*/
8080
export const getEndOfDayMillis = (date: string) => {
81-
const day = moment.default(date);
81+
const day = (moment as any)()(date);
8282
day.set({
8383
hour: 23,
8484
minute: 59,

0 commit comments

Comments
 (0)