-
Notifications
You must be signed in to change notification settings - Fork 37
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
[WIP] 564 profile image crop #598
Conversation
todo: |
current issue: |
src/app/shared/couchdb.service.ts
Outdated
@@ -82,4 +82,35 @@ export class CouchService { | |||
return obs; | |||
} | |||
|
|||
newPrepAttachment(file) { | |||
file = file.replace(/^data:image\/\w+;base64,/gi, ''); | |||
const byteCharacters = atob(file); |
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.
This is not obvious to a reader of the code, and should probably not be without commenting. If it is unclear exactly what each step does to you, at least give a reference to where you found the code snippets https://stackoverflow.com/questions/16245767/creating-a-blob-from-a-base64-string-in-javascript
Took me a little while to figure out what was meant by the lack of update: For improvements, I left one comment in the code on improved documentation, and then:
|
Found the issue you described (see bottom of post) For updated upper left corner update bug: Minimal footprint would be to emit an event such as the following in user.service.ts:
But already having userChange.next(), so could just as well piggy back on that, since not very expensive and will not happen all too often. Hence, this seems like a good place to save complexity. users-update.component.ts calls this in To not step on your toes, see possible way to change this in this branch building upon yours: Issue described not updated on save |
Hi @Tille88 thanks for finding that issue. I'm not sure what is causing the image to fail to update, but it could be related to the issue that the filename is So you and @ArashDai know, updating the user profile image in the upper right is done using the Angular suggested method for component interaction via a service (documentation). This utilizes rxjs observables which are like super powered promises if you haven't used them before. In this case we create a stream with the You picked out a mistake I made, anyway, that I think we can fix with a separate PR. I didn't think using the function for image src would be an issue, but I was debugging it and realized that it is running with every render. It's probably better to do it like you have and allow Angular to do its own change detection, and combine with Back to this issue, I think the filename is ending up |
@paulbert yes, it was the undefined image name indeed that was the issue. So going forward, is this roughly what is left to do?:
|
Also, some things that needs more permanent solution in there, but it is working again [way to generate a key, increment previous or generate ID, if id generation, where to put it in the codebase]. |
@Tille88 Thanks for working on this. To answer your questions:
As for the last two we should check different devices and make issues to improve the styling. This is already a big change, and it'll be nice to have this functionality on the master branch. |
@paulbert Thank you for the reply
uniqueId(): string {
return 'id-' + Math.random().toString(36).substr(2, 16);
}
[...]
attachments[this.uniqueId()] = [...]
// Unclear if only encoding is base64
// This ought to cover any encoding as long as the formatting is: ";[encoding],"
const imgDataArr: string[] = this.file.split(/;\w+,/); Will test out the first two bulletpoints during tonights meeting and also if there is a default crop level that would be preferred. For the 3rd and 4th, I would like some input before making alterations. |
We could fork and change the initial crop of the image if that is high enough on the priority list. Options Component controller sourcecode |
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 added a small change since handleAttachment
isn't very useful anymore (before needed to wait for async file load, now that is taken care of in the ngx-img
package).
Once this passes checks I'll merge it.
Work in progress, current issue Error: Template parse errors: There is no directive with "exportAs" set to "croppie"