-
Notifications
You must be signed in to change notification settings - Fork 62
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
Fix for uploading images. #450
Conversation
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 have serious doubt in regard to order of asynchronous code here.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
#450 (comment) Fixed in e10de92. |
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.
There are still some code to be polished.
We'll do a live-review and run though these items.
// The final URL of the file is already known, even before the upload. We save it here. | ||
returnUrl = response.asset.href; | ||
// Assign asset response to variable | ||
assetResponse = response; |
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.
Name for this variable should be improved.
assetResponse
implies that it's a response from the request made by sendAssetRequest
- while that's not the case here.
This is a result of requesting /upload/policies/assets
- so I'd say asset upload policy (with an emphasize on policy). So a more fitting name would be uploadPolicyResponse
.
Actually the comments here could be improved a bit.
return this.sendAssetRequest( assetResponse ) | ||
.then( returnUrl => { | ||
// Upload concluded! Simply send the file URL back, according to CKEditor specs. | ||
return { |
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.
Why decorating returned URL format from plain string to a object here?
Since we created a new method sendAssetRequest
, wouldn't it better to encapsulate this logic there?
github-writer/src/app/plugins/githubuploadadapter.js
Lines 248 to 251 in e10de92
.then( response => response.json() ) | |
.then( response => { | |
// The final URL of the file is already known, even before the upload. We save it here. | |
return response.href; |
default: returnUrl | ||
}; | ||
// Step 3: Retrieve the final uploaded asset URL using response data gathered on Step 1. | ||
return this.sendAssetRequest( assetResponse ) |
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.
Let the sendAssetRequest
be a private method, just like the others around here. No need to expose it.
@@ -129,10 +129,14 @@ export class Adapter { | |||
this._sendRequest( data ); | |||
} ) ) | |||
.then( ( /* { file, response } */ ) => { |
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.
Since handling here became very messy I took the liberty to extract all of these 3 promise handlers to 3 separate functions with decent names so that it's more obvious for people what they do, and so that they became somewhat more separated.
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.
Fixes added in 8e1c3b1.
Code looks good, let's wait for R+ from the QA team. Once we have it we can merge it straight away and release the fixed version!
No image preview when adding inline comment during code reviewSteps
ResultNo preview, but after a while it is possible to send comments and image show up: Nagranie.z.ekranu.2023-06-9.o.15.07.54.mov |
#450 (comment) Need to take a closer look on some |
#450 (comment) fixed in 7166dee. |
To get correct url we need to do one more fetch (like GitHub does).
Closes #444.