File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed
client/src/widgets/ribbon Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 11import { useEffect , useState } from "preact/hooks" ;
22import { TabContext } from "./ribbon-interface" ;
3- import { EditedNotesResponse } from "@triliumnext/commons" ;
3+ import { EditedNotesResponse , EditedNotes } from "@triliumnext/commons" ;
44import server from "../../services/server" ;
55import { t } from "../../services/i18n" ;
66import froca from "../../services/froca" ;
77import NoteLink from "../react/NoteLink" ;
88import { joinElements } from "../react/react_utils" ;
99
1010export default function EditedNotesTab ( { note } : TabContext ) {
11- const [ editedNotes , setEditedNotes ] = useState < EditedNotesResponse > ( ) ;
11+ const [ editedNotes , setEditedNotes ] = useState < EditedNotes > ( ) ;
1212
1313 useEffect ( ( ) => {
1414 if ( ! note ) return ;
15- server . get < EditedNotesResponse > ( `edited-notes/${ note . getLabelValue ( "dateNote" ) } ` ) . then ( async editedNotes => {
16- editedNotes = editedNotes . filter ( ( n ) => n . noteId !== note . noteId ) ;
15+ server . get < EditedNotesResponse > ( `edited-notes/${ note . getLabelValue ( "dateNote" ) } ` ) . then ( async response => {
16+ const editedNotes = response . notes . filter ( ( n ) => n . noteId !== note . noteId ) ;
1717 const noteIds = editedNotes . flatMap ( ( n ) => n . noteId ) ;
1818 await froca . getNotes ( noteIds , true ) ; // preload all at once
1919 setEditedNotes ( editedNotes ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import becca from "../../becca/becca.js";
66import type { Request } from "express" ;
77import { NotePojo } from "../../becca/becca-interface.js" ;
88import type BNote from "../../becca/entities/bnote.js" ;
9- import { EditedNotesResponse } from "@triliumnext/commons" ;
9+ import { EditedNotes , EditedNotesResponse } from "@triliumnext/commons" ;
1010import dateUtils from "../../services/date_utils.js" ;
1111
1212interface NotePath {
@@ -53,14 +53,18 @@ function getEditedNotesOnDate(req: Request) {
5353 notes = notes . filter ( ( note ) => note . hasAncestor ( hoistedNoteId ) ) ;
5454 }
5555
56- return notes . map ( ( note ) => {
56+ const editedNotes = notes . map ( ( note ) => {
5757 const notePath = getNotePathData ( note ) ;
5858
5959 const notePojo : NotePojoWithNotePath = note . getPojo ( ) ;
6060 notePojo . notePath = notePath ? notePath . notePath : null ;
6161
6262 return notePojo ;
63- } ) satisfies EditedNotesResponse ;
63+ } ) ;
64+
65+ return {
66+ notes : editedNotes ,
67+ } satisfies EditedNotesResponse ;
6468}
6569
6670function getNotePathData ( note : BNote ) : NotePath | undefined {
Original file line number Diff line number Diff line change @@ -164,11 +164,17 @@ export type ToggleInParentResponse = {
164164}
165165
166166export type EditedNotesResponse = {
167+ notes : EditedNotes ,
168+ }
169+
170+ export type EditedNote = {
167171 noteId : string ;
168172 isDeleted : boolean ;
169173 title ?: string ;
170174 notePath ?: string [ ] | null ;
171- } [ ] ;
175+ } ;
176+
177+ export type EditedNotes = EditedNote [ ] ;
172178
173179export interface MetadataResponse {
174180 dateCreated : string | undefined ;
You can’t perform that action at this time.
0 commit comments