-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TW-692: Implement
UploadProfile
in presentation layer
- Loading branch information
Showing
26 changed files
with
1,019 additions
and
545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tate/settings/upload_profile_failure.dart → ...tate/settings/update_profile_failure.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...tate/settings/upload_profile_loading.dart → ...tate/settings/update_profile_loading.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:fluffychat/app_state/success.dart'; | ||
|
||
class UpdateProfileInitial extends Success { | ||
@override | ||
List<Object?> get props => []; | ||
} | ||
|
||
class UpdateProfileSuccess extends Success { | ||
final Uri? avatar; | ||
final String? displayName; | ||
final bool isDeleteAvatar; | ||
|
||
const UpdateProfileSuccess({ | ||
this.avatar, | ||
this.displayName, | ||
this.isDeleteAvatar = false, | ||
}); | ||
|
||
@override | ||
List<Object?> get props => [avatar, displayName, isDeleteAvatar]; | ||
} |
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
lib/domain/usecase/settings/update_profile_interactor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:dartz/dartz.dart'; | ||
import 'package:fluffychat/app_state/failure.dart'; | ||
import 'package:fluffychat/app_state/success.dart'; | ||
import 'package:fluffychat/domain/app_state/settings/update_profile_failure.dart'; | ||
import 'package:fluffychat/domain/app_state/settings/update_profile_loading.dart'; | ||
import 'package:fluffychat/domain/app_state/settings/update_profile_success.dart'; | ||
import 'package:matrix/matrix.dart'; | ||
|
||
class UpdateProfileInteractor { | ||
Stream<Either<Failure, Success>> execute({ | ||
required Client client, | ||
Uri? avatarUrl, | ||
bool isDeleteAvatar = false, | ||
String? displayName, | ||
}) async* { | ||
yield const Right(UpdateProfileLoading()); | ||
try { | ||
Logs().d( | ||
'UploadProfileInteractor::execute(): Uri - $avatarUrl - displayName - $displayName', | ||
); | ||
if (avatarUrl != null || isDeleteAvatar) { | ||
await client.setAvatarUrl( | ||
client.userID!, | ||
avatarUrl ?? Uri.parse(''), | ||
); | ||
} | ||
if (displayName != null) { | ||
await client.setDisplayName( | ||
client.userID!, | ||
displayName, | ||
); | ||
} | ||
yield Right( | ||
UpdateProfileSuccess( | ||
displayName: displayName, | ||
avatar: avatarUrl, | ||
isDeleteAvatar: isDeleteAvatar, | ||
), | ||
); | ||
} catch (e) { | ||
Logs().d( | ||
'UploadAvatarInteractor::execute(): Exception - $e}', | ||
); | ||
yield Left(UpdateProfileFailure(e)); | ||
} | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
lib/domain/usecase/settings/upload_profile_interactor.dart
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.