File tree Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,16 @@ import type { Note } from '@/domain/entities/Note';
5
5
import { noteHistoryService } from '@/domain' ;
6
6
7
7
interface UseNoteHistoryComposableState {
8
+ /**
9
+ * Note hisotry is array of the history meta used for history preview
10
+ */
8
11
noteHistory : Ref < NoteHistoryMeta [ ] | null > ;
9
12
}
10
13
11
14
interface UseNoteHistoryComposableOptions {
15
+ /**
16
+ * Id of the note
17
+ */
12
18
noteId : MaybeRefOrGetter < NoteHistoryRecord [ 'noteId' ] | null > ;
13
19
}
14
20
@@ -21,6 +27,9 @@ export default function useNoteHistory(options: UseNoteHistoryComposableOptions)
21
27
noteHistory . value = await noteHistoryService . loadNoteHistory ( noteId ) ;
22
28
}
23
29
30
+ /**
31
+ * When page is mounted, we should load note history
32
+ */
24
33
onMounted ( ( ) => {
25
34
if ( currentNoteId . value !== null ) {
26
35
void loadNoteHistory ( currentNoteId . value ) ;
Original file line number Diff line number Diff line change 1
1
import type { NoteHistoryMeta } from './entities/History' ;
2
2
import type { Note } from './entities/Note' ;
3
3
4
+ /**
5
+ * Interface of the note history repository
6
+ */
4
7
export default interface NoteHistoryRepositoryInterface {
5
8
/**
6
9
* Loads note history meta for note history preview
Original file line number Diff line number Diff line change @@ -2,13 +2,24 @@ import type { NoteHistoryMeta } from './entities/History';
2
2
import type { Note } from './entities/Note' ;
3
3
import type NoteHistoryRepository from './noteHistory.repository.interface' ;
4
4
5
+ /**
6
+ * Note history service class, used for logic handling of the data,
7
+ * Also used for data delivery from repository to application service
8
+ */
5
9
export default class NoteHistoryService {
10
+ /**
11
+ * Note history repository instance
12
+ */
6
13
private readonly noteHistoryRepository : NoteHistoryRepository ;
7
14
8
15
constructor ( historyRepository : NoteHistoryRepository ) {
9
16
this . noteHistoryRepository = historyRepository ;
10
17
}
11
18
19
+ /**
20
+ * Loads note history meta for note history preview
21
+ * @param noteId - id of the note
22
+ */
12
23
public async loadNoteHistory ( noteId : Note [ 'id' ] ) : Promise < NoteHistoryMeta [ ] > {
13
24
return await this . noteHistoryRepository . loadNoteHistory ( noteId ) ;
14
25
}
Original file line number Diff line number Diff line change @@ -3,19 +3,26 @@ import type NotesApiTransport from './transport/notes-api';
3
3
import type { Note } from '@/domain/entities/Note' ;
4
4
import type { NoteHistoryMeta } from '@/domain/entities/History' ;
5
5
6
+ /**
7
+ * Note history repository class used for data delivery from transport to service
8
+ */
6
9
export default class NoteHistoryRepository implements NoteHistoryRepositoryInterface {
10
+ /**
11
+ * Notes api transport instance
12
+ */
7
13
private readonly transport : NotesApiTransport ;
8
14
9
15
constructor ( notesApiTransport : NotesApiTransport ) {
10
16
this . transport = notesApiTransport ;
11
17
}
12
18
19
+ /**
20
+ * Loads note history meta for note history preview
21
+ * @param noteId - id of the note
22
+ */
13
23
public async loadNoteHistory ( noteId : Note [ 'id' ] ) : Promise < NoteHistoryMeta [ ] > {
14
- console . log ( 'noteIID' , noteId ) ;
15
24
const response = await this . transport . get < { noteHistoryMeta : NoteHistoryMeta [ ] } > ( `/note/${ noteId } /history` ) ;
16
25
17
- console . log ( 'resssssss' , response ) ;
18
-
19
26
return response . noteHistoryMeta ;
20
27
}
21
28
}
You can’t perform that action at this time.
0 commit comments