Skip to content

Commit ead0664

Browse files
chore: methods rename
1 parent f5e0a59 commit ead0664

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/document/document_repository.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ final class DocumentRepositoryImpl implements DocumentRepository {
256256
@override
257257
Future<List<DocumentData>> findAllVersions({required DocumentRef ref}) async {
258258
final all = switch (ref) {
259-
DraftRef() => await _drafts.getAll(ref: ref),
260-
SignedDocumentRef() => await _localDocuments.getAll(ref: ref),
259+
DraftRef() => await _drafts.findAll(ref: ref),
260+
SignedDocumentRef() => await _localDocuments.findAll(ref: ref),
261261
}..sort();
262262

263263
return all;
@@ -267,8 +267,8 @@ final class DocumentRepositoryImpl implements DocumentRepository {
267267
Future<List<DocumentData>> getAllVersionsOfId({
268268
required String id,
269269
}) async {
270-
final localRefs = await _localDocuments.getAll(ref: SignedDocumentRef(id: id));
271-
final drafts = await _drafts.getAll(ref: DraftRef(id: id));
270+
final localRefs = await _localDocuments.findAll(ref: SignedDocumentRef(id: id));
271+
final drafts = await _drafts.findAll(ref: DraftRef(id: id));
272272

273273
return [...drafts, ...localRefs];
274274
}
@@ -298,8 +298,8 @@ final class DocumentRepositoryImpl implements DocumentRepository {
298298
Future<DocumentData?> getLatestDocument({
299299
CatalystId? authorId,
300300
}) async {
301-
final latestDocument = await _localDocuments.getWhere(authorId: authorId);
302-
final latestDraft = await _drafts.getWhere();
301+
final latestDocument = await _localDocuments.findFirst(authorId: authorId);
302+
final latestDraft = await _drafts.findFirst();
303303

304304
return [latestDocument, latestDraft].nonNulls.sorted((a, b) => a.compareTo(b)).firstOrNull;
305305
}
@@ -328,7 +328,7 @@ final class DocumentRepositoryImpl implements DocumentRepository {
328328
required DocumentRef refTo,
329329
required DocumentType type,
330330
}) {
331-
return _localDocuments.getWhere(refTo: refTo, type: type);
331+
return _localDocuments.findFirst(refTo: refTo, type: type);
332332
}
333333

334334
@override
@@ -384,9 +384,9 @@ final class DocumentRepositoryImpl implements DocumentRepository {
384384
bool includeLocalDrafts = false,
385385
}) async {
386386
List<DocumentData> documents;
387-
final localDocuments = await _localDocuments.getAll(ref: SignedDocumentRef(id: id));
387+
final localDocuments = await _localDocuments.findAll(ref: SignedDocumentRef(id: id));
388388
if (includeLocalDrafts) {
389-
final localDrafts = await _drafts.getAll(ref: DraftRef(id: id));
389+
final localDrafts = await _drafts.findAll(ref: DraftRef(id: id));
390390
documents = [...localDocuments, ...localDrafts];
391391
} else {
392392
documents = localDocuments;

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/document/source/database_documents_data_source.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ final class DatabaseDocumentsDataSource
5050
}
5151

5252
@override
53-
Future<DocumentData?> get(DocumentRef ref) => getWhere(ref: ref);
54-
55-
@override
56-
Future<List<DocumentData>> getAll({
53+
Future<List<DocumentData>> findAll({
5754
DocumentType? type,
5855
DocumentRef? ref,
5956
DocumentRef? refTo,
@@ -73,6 +70,21 @@ final class DatabaseDocumentsDataSource
7370
.then((value) => value.map((e) => e.toModel()).toList());
7471
}
7572

73+
@override
74+
Future<DocumentData?> findFirst({
75+
DocumentType? type,
76+
DocumentRef? ref,
77+
DocumentRef? refTo,
78+
CatalystId? authorId,
79+
}) {
80+
return _database.documentsV2Dao
81+
.getDocument(type: type, ref: ref, refTo: refTo, author: authorId)
82+
.then((value) => value?.toModel());
83+
}
84+
85+
@override
86+
Future<DocumentData?> get(DocumentRef ref) => findFirst(ref: ref);
87+
7688
@override
7789
Future<DocumentRef?> getLatestRefOf(DocumentRef ref) {
7890
return _database.documentsV2Dao.getLatestOf(ref);
@@ -86,18 +98,6 @@ final class DatabaseDocumentsDataSource
8698
return _database.proposalsV2Dao.getProposalsTotalTask(filters: filters, nodeId: nodeId);
8799
}
88100

89-
@override
90-
Future<DocumentData?> getWhere({
91-
DocumentType? type,
92-
DocumentRef? ref,
93-
DocumentRef? refTo,
94-
CatalystId? authorId,
95-
}) {
96-
return _database.documentsV2Dao
97-
.getDocument(type: type, ref: ref, refTo: refTo, author: authorId)
98-
.then((value) => value?.toModel());
99-
}
100-
101101
@override
102102
Future<void> save({required DocumentData data}) => saveAll([data]);
103103

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/document/source/database_drafts_data_source.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ final class DatabaseDraftsDataSource implements DraftDataSource {
4040
}
4141

4242
@override
43-
Future<DocumentData?> get(DocumentRef ref) => getWhere(ref: ref);
44-
45-
@override
46-
Future<List<DocumentData>> getAll({
43+
Future<List<DocumentData>> findAll({
4744
DocumentType? type,
4845
DocumentRef? ref,
4946
DocumentRef? refTo,
@@ -64,12 +61,7 @@ final class DatabaseDraftsDataSource implements DraftDataSource {
6461
}
6562

6663
@override
67-
Future<DocumentRef?> getLatestRefOf(DocumentRef ref) async {
68-
return _database.localDocumentsV2Dao.getLatestOf(ref);
69-
}
70-
71-
@override
72-
Future<DocumentData?> getWhere({
64+
Future<DocumentData?> findFirst({
7365
DocumentType? type,
7466
DocumentRef? ref,
7567
DocumentRef? refTo,
@@ -79,6 +71,14 @@ final class DatabaseDraftsDataSource implements DraftDataSource {
7971
.then((value) => value?.toModel());
8072
}
8173

74+
@override
75+
Future<DocumentData?> get(DocumentRef ref) => findFirst(ref: ref);
76+
77+
@override
78+
Future<DocumentRef?> getLatestRefOf(DocumentRef ref) async {
79+
return _database.localDocumentsV2Dao.getLatestOf(ref);
80+
}
81+
8282
@override
8383
Future<void> save({required DocumentData data}) => saveAll([data]);
8484

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/document/source/document_data_local_source.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ abstract interface class DocumentDataLocalSource implements DocumentDataSource {
4040
/// * [latestOnly]: If `true`, only the most recent version of each
4141
/// document ID is returned.
4242
/// * [limit] and [offset]: Used for pagination.
43-
Future<List<DocumentData>> getAll({
43+
Future<List<DocumentData>> findAll({
4444
DocumentType? type,
4545
DocumentRef? ref,
4646
DocumentRef? refTo,
@@ -53,7 +53,7 @@ abstract interface class DocumentDataLocalSource implements DocumentDataSource {
5353
///
5454
/// Returns `null` if no document matches or if multiple match (depending on impl).
5555
/// Generally used when the filter is expected to yield a unique result.
56-
Future<DocumentData?> getWhere({
56+
Future<DocumentData?> findFirst({
5757
DocumentType? type,
5858
DocumentRef? ref,
5959
DocumentRef? refTo,

catalyst_voices/packages/internal/catalyst_voices_repositories/lib/src/document/source/signed_document_data_local_source.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ abstract interface class SignedDocumentDataSource implements DocumentDataLocalSo
1111
///
1212
/// * [authorId]: Filters documents authored by a specific [CatalystId].
1313
@override
14-
Future<DocumentData?> getWhere({
14+
Future<DocumentData?> findFirst({
1515
DocumentType? type,
1616
DocumentRef? ref,
1717
DocumentRef? refTo,

0 commit comments

Comments
 (0)