mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	client-ts: Port services/app/date_notes
This commit is contained in:
		| @@ -1,67 +1,61 @@ | ||||
| import dayjs from "dayjs"; | ||||
| import { FNoteRow } from "../entities/fnote.js"; | ||||
| import froca from "./froca.js"; | ||||
| import server from "./server.js"; | ||||
| import ws from "./ws.js"; | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getInboxNote() { | ||||
|     const note = await server.get(`special-notes/inbox/${dayjs().format("YYYY-MM-DD")}`, "date-note"); | ||||
|     const note = await server.get<FNoteRow>(`special-notes/inbox/${dayjs().format("YYYY-MM-DD")}`, "date-note"); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getTodayNote() { | ||||
|     return await getDayNote(dayjs().format("YYYY-MM-DD")); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getDayNote(date) { | ||||
|     const note = await server.get(`special-notes/days/${date}`, "date-note"); | ||||
| async function getDayNote(date: string) { | ||||
|     const note = await server.get<FNoteRow>(`special-notes/days/${date}`, "date-note"); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getWeekNote(date) { | ||||
|     const note = await server.get(`special-notes/weeks/${date}`, "date-note"); | ||||
| async function getWeekNote(date: string) { | ||||
|     const note = await server.get<FNoteRow>(`special-notes/weeks/${date}`, "date-note"); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getMonthNote(month) { | ||||
|     const note = await server.get(`special-notes/months/${month}`, "date-note"); | ||||
| async function getMonthNote(month: string) { | ||||
|     const note = await server.get<FNoteRow>(`special-notes/months/${month}`, "date-note"); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function getYearNote(year) { | ||||
|     const note = await server.get(`special-notes/years/${year}`, "date-note"); | ||||
| async function getYearNote(year: string) { | ||||
|     const note = await server.get<FNoteRow>(`special-notes/years/${year}`, "date-note"); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function createSqlConsole() { | ||||
|     const note = await server.post('special-notes/sql-console'); | ||||
|     const note = await server.post<FNoteRow>('special-notes/sql-console'); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
|     return await froca.getNote(note.noteId); | ||||
| } | ||||
| 
 | ||||
| /** @returns {FNote} */ | ||||
| async function createSearchNote(opts = {}) { | ||||
|     const note = await server.post('special-notes/search-note', opts); | ||||
|     const note = await server.post<FNoteRow>('special-notes/search-note', opts); | ||||
| 
 | ||||
|     await ws.waitForMaxKnownEntityChangeId(); | ||||
| 
 | ||||
		Reference in New Issue
	
	Block a user