Skip to content

Commit 26b2047

Browse files
committed
added todo
1 parent 4fae8eb commit 26b2047

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

src/application/services/useNoteHistory.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ import type { Note } from '@/domain/entities/Note';
55
import { noteHistoryService } from '@/domain';
66

77
interface UseNoteHistoryComposableState {
8+
/**
9+
* Note hisotry is array of the history meta used for history preview
10+
*/
811
noteHistory: Ref<NoteHistoryMeta[] | null>;
912
}
1013

1114
interface UseNoteHistoryComposableOptions {
15+
/**
16+
* Id of the note
17+
*/
1218
noteId: MaybeRefOrGetter<NoteHistoryRecord['noteId'] | null>;
1319
}
1420

@@ -21,6 +27,9 @@ export default function useNoteHistory(options: UseNoteHistoryComposableOptions)
2127
noteHistory.value = await noteHistoryService.loadNoteHistory(noteId);
2228
}
2329

30+
/**
31+
* When page is mounted, we should load note history
32+
*/
2433
onMounted(() => {
2534
if (currentNoteId.value !== null) {
2635
void loadNoteHistory(currentNoteId.value);

src/domain/noteHistory.repository.interface.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import type { NoteHistoryMeta } from './entities/History';
22
import type { Note } from './entities/Note';
33

4+
/**
5+
* Interface of the note history repository
6+
*/
47
export default interface NoteHistoryRepositoryInterface {
58
/**
69
* Loads note history meta for note history preview

src/domain/noteHistory.service.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@ import type { NoteHistoryMeta } from './entities/History';
22
import type { Note } from './entities/Note';
33
import type NoteHistoryRepository from './noteHistory.repository.interface';
44

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+
*/
59
export default class NoteHistoryService {
10+
/**
11+
* Note history repository instance
12+
*/
613
private readonly noteHistoryRepository: NoteHistoryRepository;
714

815
constructor(historyRepository: NoteHistoryRepository) {
916
this.noteHistoryRepository = historyRepository;
1017
}
1118

19+
/**
20+
* Loads note history meta for note history preview
21+
* @param noteId - id of the note
22+
*/
1223
public async loadNoteHistory(noteId: Note['id']): Promise<NoteHistoryMeta[]> {
1324
return await this.noteHistoryRepository.loadNoteHistory(noteId);
1425
}

src/infrastructure/noteHistory.repository.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@ import type NotesApiTransport from './transport/notes-api';
33
import type { Note } from '@/domain/entities/Note';
44
import type { NoteHistoryMeta } from '@/domain/entities/History';
55

6+
/**
7+
* Note history repository class used for data delivery from transport to service
8+
*/
69
export default class NoteHistoryRepository implements NoteHistoryRepositoryInterface {
10+
/**
11+
* Notes api transport instance
12+
*/
713
private readonly transport: NotesApiTransport;
814

915
constructor(notesApiTransport: NotesApiTransport) {
1016
this.transport = notesApiTransport;
1117
}
1218

19+
/**
20+
* Loads note history meta for note history preview
21+
* @param noteId - id of the note
22+
*/
1323
public async loadNoteHistory(noteId: Note['id']): Promise<NoteHistoryMeta[]> {
14-
console.log('noteIID', noteId);
1524
const response = await this.transport.get<{ noteHistoryMeta: NoteHistoryMeta[] }>(`/note/${noteId}/history`);
1625

17-
console.log('resssssss', response);
18-
1926
return response.noteHistoryMeta;
2027
}
2128
}

0 commit comments

Comments
 (0)