-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of updating user avatar. #1549
Conversation
val workerParams = UploadAvatarWorker.Params(sessionId, newAvatarUri, fileName) | ||
val workerData = WorkerParamsFactory.toData(workerParams) | ||
|
||
val uploadAvatarWork = workManagerProvider.matrixOneTimeWorkRequestBuilder<UploadAvatarWorker>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to make uploading avatar uses a worker. It's alright if it fails, we'll get an error and can retry later. What do you think about that @bmarty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code is more complicated that I'd expect it to be. We should use the uploadService facilities. I have not checked in the code if it is possible.
* @param newAvatarUri the new avatar uri of the user | ||
* @param fileName the fileName of selected image | ||
*/ | ||
fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String, matrixCallback: MatrixCallback<Unit>): Cancelable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update avatar of other users? otherwise, we should not offer the userId param and inject @userid instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Matrix API takes a userId, that's why it's exposed here... But yes in the app, it will be only possible to change avatar of the current user.
val uri = image.contentUri | ||
UCrop.of(uri, destinationFile.toUri()) | ||
.withOptions( | ||
UCrop.Options() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't check, but if Ucrop options are the same than for attachment, we should extract this in a helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not the same that for attachment. We should limit to a square image, or if possible a round image. But yes it should be extracted and not copy-paste multiple times
val result = WorkerParamsFactory.fromData<UploadAvatarWorker.OutputParams>(info.outputData) | ||
cancelableBag.add( | ||
setAvatarUrlTask | ||
.configureWith(SetAvatarUrlTask.Params(userId = userId, newAvatarUrl = result?.imageUrl!!)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would put the !!
to result
instead
// ============================================================================================================== | ||
// contacts management | ||
// ============================================================================================================== | ||
// ============================================================================================================== |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert those fomartting change
Fixes #1054