Skip to content

Commit

Permalink
Change HomeworkDialogApi.edit to take HomeworkId instead of `Home…
Browse files Browse the repository at this point in the history
…workDto oldHomework`.
  • Loading branch information
Jonas-Sander committed Oct 12, 2023
1 parent 3f4b4e9 commit 00ab30d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app/lib/blocs/homework/homework_dialog_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ class HomeworkDialogBloc extends BlocBase {
final removedCloudFiles = matchRemovedCloudFilesFromTwoList(
initialCloudFiles, _cloudFilesSubject.valueOrNull!);
if (hasAttachments) {
await api.edit(initialHomework!, userInput,
await api.edit(HomeworkId(initialHomework!.id), userInput,
removedCloudFiles: removedCloudFiles);
} else {
api.edit(initialHomework!, userInput,
api.edit(HomeworkId(initialHomework!.id), userInput,
removedCloudFiles: removedCloudFiles);
}

Expand Down Expand Up @@ -443,8 +443,10 @@ class HomeworkDialogApi {
return homework;
}

Future<HomeworkDto> edit(HomeworkDto oldHomework, UserInput userInput,
Future<HomeworkDto> edit(HomeworkId homeworkId, UserInput userInput,
{List<CloudFile> removedCloudFiles = const []}) async {
final oldHomework =
await _api.homework.singleHomeworkStream(homeworkId.id).first;
List<String> attachments = oldHomework.attachments.toList();
final editorName = (await _api.user.userStream.first)!.name;
final editorID = _api.user.authUser!.uid;
Expand Down
2 changes: 1 addition & 1 deletion app/test/homework/homework_dialog_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MockHomeworkDialogApi implements HomeworkDialogApi {
late UserInput userInputFromEditing;
late List<CloudFile> removedCloudFilesFromEditing;
@override
Future<HomeworkDto> edit(HomeworkDto oldHomework, UserInput userInput,
Future<HomeworkDto> edit(HomeworkId homeworkId, UserInput userInput,
{List<CloudFile> removedCloudFiles = const []}) async {
userInputFromEditing = userInput;
removedCloudFilesFromEditing = removedCloudFiles;
Expand Down

0 comments on commit 00ab30d

Please sign in to comment.