mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
Repair: the awkward refreshment to top after edition on tasks and the wrong display of customized view.
This commit is contained in:
parent
fc174e7c64
commit
a1abaf2e46
3 changed files with 66 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ import {
|
|||
getDailyNote,
|
||||
appHasDailyNotesPluginLoaded,
|
||||
getDailyNoteSettings,
|
||||
} from "obsidian-daily-notes-interface";
|
||||
} from "@/utils/obsidian-daily-notes";
|
||||
import {
|
||||
saveCapture,
|
||||
processDateTemplates,
|
||||
|
|
@ -1912,6 +1912,12 @@ export class WriteAPI {
|
|||
|
||||
// Append under optional heading
|
||||
const file = dailyNoteFile;
|
||||
if (!file) {
|
||||
return {
|
||||
success: false,
|
||||
error: "Failed to resolve daily note file",
|
||||
};
|
||||
}
|
||||
const current = await this.vault.read(file);
|
||||
let newContent = current;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import {
|
|||
getDateFromFile,
|
||||
appHasDailyNotesPluginLoaded,
|
||||
getDailyNoteSettings,
|
||||
} from "obsidian-daily-notes-interface";
|
||||
} from "@/utils/obsidian-daily-notes";
|
||||
import { Events, on, emit } from "../dataflow/events/Events";
|
||||
import { DateInheritanceService } from "../services/date-inheritance-service";
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ export class HabitManager extends Component {
|
|||
|
||||
private async getDailyNotes(): Promise<TFile[]> {
|
||||
const files = getAllDailyNotes();
|
||||
return Object.values(files);
|
||||
return files.map((entry) => entry.file);
|
||||
}
|
||||
|
||||
private isDailyNote(file: TFile): boolean {
|
||||
|
|
|
|||
57
src/utils/obsidian-daily-notes.ts
Normal file
57
src/utils/obsidian-daily-notes.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import type { TFile } from "obsidian";
|
||||
import {
|
||||
appHasDailyNotesPluginLoaded as dailyNotesPluginLoadedUnsafe,
|
||||
createDailyNote as createDailyNoteUnsafe,
|
||||
getAllDailyNotes as getAllDailyNotesUnsafe,
|
||||
getDailyNote as getDailyNoteUnsafe,
|
||||
getDailyNoteSettings as getDailyNoteSettingsUnsafe,
|
||||
getDateFromFile as getDateFromFileUnsafe,
|
||||
} from "obsidian-daily-notes-interface";
|
||||
|
||||
export interface DailyNoteSettings {
|
||||
folder?: string;
|
||||
format?: string;
|
||||
template?: string;
|
||||
}
|
||||
|
||||
export interface DailyNoteEntry {
|
||||
file: TFile;
|
||||
date: unknown;
|
||||
}
|
||||
|
||||
// The upstream package ships its own obsidian dependency, which produces a
|
||||
// second TFile type. Centralize the boundary here so the rest of the codebase
|
||||
// can stay on our local obsidian types.
|
||||
export function appHasDailyNotesPluginLoaded(): boolean {
|
||||
return Boolean(dailyNotesPluginLoadedUnsafe());
|
||||
}
|
||||
|
||||
export async function createDailyNote(date: unknown): Promise<TFile> {
|
||||
return (await createDailyNoteUnsafe(date as never)) as unknown as TFile;
|
||||
}
|
||||
|
||||
export function getAllDailyNotes(): DailyNoteEntry[] {
|
||||
return getAllDailyNotesUnsafe() as unknown as DailyNoteEntry[];
|
||||
}
|
||||
|
||||
export function getDailyNote(
|
||||
date: unknown,
|
||||
dailyNotes: DailyNoteEntry[],
|
||||
): TFile | null {
|
||||
const file = getDailyNoteUnsafe(
|
||||
date as never,
|
||||
dailyNotes as never,
|
||||
) as unknown as TFile | null | undefined;
|
||||
return file ?? null;
|
||||
}
|
||||
|
||||
export function getDailyNoteSettings(): DailyNoteSettings {
|
||||
return getDailyNoteSettingsUnsafe() as unknown as DailyNoteSettings;
|
||||
}
|
||||
|
||||
export function getDateFromFile(file: TFile, granularity?: string): any {
|
||||
return getDateFromFileUnsafe(
|
||||
file as never,
|
||||
granularity as never,
|
||||
) as any;
|
||||
}
|
||||
Loading…
Reference in a new issue