Merge pull request #383 from decaf-dev/dev

Fix build errors
This commit is contained in:
DecafDev 2025-05-02 20:24:01 -06:00 committed by GitHub
commit 38f8c8225f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 37 additions and 27 deletions

View file

@ -1,28 +1,33 @@
import { Modal } from "obsidian";
import CustomFilterApp from "../svelte/custom-filter-app/index.svelte";
import VaultExplorerPlugin from "src/main";
import { mount, unmount } from "svelte";
import CustomFilterApp from "../svelte/custom-filter-app/index.svelte";
export default class CustomFilterModal extends Modal {
component: CustomFilterApp | null;
customFilterApp: ReturnType<typeof mount> | null;
plugin: VaultExplorerPlugin;
constructor(plugin: VaultExplorerPlugin) {
super(plugin.app);
this.plugin = plugin;
this.component = null;
this.customFilterApp = null;
}
onOpen(): void {
const { contentEl } = this;
this.component = new CustomFilterApp({
this.customFilterApp = mount(CustomFilterApp, {
target: contentEl
});
}
onClose(): void {
const { contentEl } = this;
this.component?.$destroy();
if (this.customFilterApp) {
unmount(this.customFilterApp);
}
contentEl.empty();
}
}

View file

@ -26,11 +26,12 @@ import { TExplorerView } from "src/types";
import ImageSourceApp from "../svelte/image-source-app/index.svelte";
import { clearSMICache } from "src/svelte/app/services/smi-cache";
import { mount, unmount } from "svelte";
export default class VaultExplorerSettingsTab extends PluginSettingTab {
plugin: VaultExplorerPlugin;
imageSourceApp: ImageSourceApp | null;
imageSourceApp: ReturnType<typeof mount> | null;
constructor(app: App, plugin: VaultExplorerPlugin) {
super(app, plugin);
@ -230,7 +231,7 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
new Setting(containerEl).setName("Grid view").setHeading();
this.imageSourceApp = new ImageSourceApp({
this.imageSourceApp = mount(ImageSourceApp, {
target: containerEl
});
@ -683,7 +684,9 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
}
onClose() {
this.imageSourceApp?.$destroy();
if (this.imageSourceApp) {
unmount(this.imageSourceApp);
}
}
private updateViewOrder(

View file

@ -1,18 +1,19 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import { VAULT_EXPLORER_VIEW } from "src/constants";
import VaultExplorerApp from "../svelte/app/index.svelte";
import VaultExplorerPlugin from "src/main";
import EventManager from "src/event/event-manager";
import { PluginEvent } from "src/event/types";
import VaultExplorerPlugin from "src/main";
import { mount, unmount } from "svelte";
import VaultExplorerApp from "../svelte/app/index.svelte";
export default class VaultExplorerView extends ItemView {
component: VaultExplorerApp | null;
vaultExplorerApp: ReturnType<typeof mount> | null;
plugin: VaultExplorerPlugin;
constructor(leaf: WorkspaceLeaf, plugin: VaultExplorerPlugin) {
super(leaf);
this.component = null;
this.vaultExplorerApp = null;
this.plugin = plugin;
this.navigation = true;
}
@ -43,12 +44,14 @@ export default class VaultExplorerView extends ItemView {
const containerEl = this.containerEl.children[1];
this.component = new VaultExplorerApp({
this.vaultExplorerApp = mount(VaultExplorerApp, {
target: containerEl
});
}
async onClose() {
this.component?.$destroy();
if (this.vaultExplorerApp) {
unmount(this.vaultExplorerApp);
}
}
}

View file

@ -1,8 +1,8 @@
import { moment } from "obsidian";
export const formatAsBearTimeString = (milliseconds: number) => {
const now = moment.default();
const time = moment.default(milliseconds);
const now = (moment as any)();
const time = (moment as any)(milliseconds);
const diffInSeconds = now.diff(time, "seconds");
const diffInMinutes = now.diff(time, "minutes");

View file

@ -104,4 +104,3 @@
background-color: var(--background-modifier-hover);
}
</style>
``

View file

@ -7,7 +7,7 @@ const DATE_FORMATS = ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DDTHH:mm", "YYYY-MM-DD"];
* @returns - The current time in milliseconds
*/
export const getStartOfTodayMillis = () => {
return moment.default().startOf("day").valueOf();
return (moment as any)().startOf("day").valueOf();
};
/**
@ -16,7 +16,7 @@ export const getStartOfTodayMillis = () => {
* @returns - The start of the day in milliseconds
*/
export const getStartOfDayMillis = (date: string) => {
return moment.default(date).startOf("day").valueOf();
return (moment as any)(date).startOf("day").valueOf();
};
/**
@ -24,19 +24,19 @@ export const getStartOfDayMillis = (date: string) => {
* @returns - The start of the week in milliseconds
*/
export const getStartOfThisWeekMillis = () => {
return moment.default().startOf("week").valueOf();
return (moment as any)().startOf("week").valueOf();
};
export const getMomentDate = (date: string) => {
return moment.default(date, DATE_FORMATS, true);
return (moment as any)(date, DATE_FORMATS, true);
};
export const getDateDaysAgo = (daysAgo: number) => {
return moment.default().subtract(daysAgo, "days").format("YYYY-MM-DD");
return (moment as any)().subtract(daysAgo, "days").format("YYYY-MM-DD");
};
export const getDateDaysAhead = (daysAgo: number) => {
return moment.default().add(daysAgo, "days").format("YYYY-MM-DD");
return (moment as any)().add(daysAgo, "days").format("YYYY-MM-DD");
};
/**
@ -45,7 +45,7 @@ export const getDateDaysAhead = (daysAgo: number) => {
*/
export const getStartOfLastWeekMillis = () => {
//This is the Sunday the previous week
return moment.default().subtract(1, "weeks").startOf("week").valueOf();
return (moment as any)().subtract(1, "weeks").startOf("week").valueOf();
};
/**
@ -54,7 +54,7 @@ export const getStartOfLastWeekMillis = () => {
* @returns - The date in milliseconds
*/
export const getTimeMillis = (date: string) => {
const momentDate = moment.default(date, DATE_FORMATS, true);
const momentDate = (moment as any)()(date, DATE_FORMATS, true);
if (!momentDate.isValid()) {
throw new Error(`Date format not handled: ${date}`);
@ -68,7 +68,7 @@ export const getTimeMillis = (date: string) => {
* @returns - True if the date is supported, false otherwise
*/
export const isDateSupported = (date: string) => {
const momentDate = moment.default(date, DATE_FORMATS, true);
const momentDate = (moment as any)()(date, DATE_FORMATS, true);
return momentDate.isValid();
};
@ -78,7 +78,7 @@ export const isDateSupported = (date: string) => {
* @returns - The end of the day in milliseconds
*/
export const getEndOfDayMillis = (date: string) => {
const day = moment.default(date);
const day = (moment as any)()(date);
day.set({
hour: 23,
minute: 59,