Skip to content
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

Merged
merged 2 commits into from
Jun 29, 2020

Conversation

onurays
Copy link
Contributor

@onurays onurays commented Jun 25, 2020

Fixes #1054

@onurays onurays requested a review from bmarty June 25, 2020 11:40
@onurays onurays self-assigned this Jun 25, 2020
@onurays onurays linked an issue Jun 25, 2020 that may be closed by this pull request
@onurays onurays requested a review from ganfra June 25, 2020 11:52
val workerParams = UploadAvatarWorker.Params(sessionId, newAvatarUri, fileName)
val workerData = WorkerParamsFactory.toData(workerParams)

val uploadAvatarWork = workManagerProvider.matrixOneTimeWorkRequestBuilder<UploadAvatarWorker>()
Copy link
Member

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 ?

Copy link
Member

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
Copy link
Member

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

Copy link
Member

@bmarty bmarty Jun 26, 2020

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()
Copy link
Member

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

Copy link
Member

@bmarty bmarty Jun 26, 2020

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!!)) {
Copy link
Member

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
// ==============================================================================================================
// ==============================================================================================================
Copy link
Member

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

@onurays onurays merged commit 188b028 into feature/room_settings Jun 29, 2020
@onurays onurays deleted the feature/update_user_avatar branch June 29, 2020 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update user avatar
3 participants