Stopping posts being made while rich-embed preview processing #2418
Summary
Closes #2418
Original change on prod is that if you hit enter too quickly after posting a link, it will not post with the rich embed preview. That will upload in a separate comment below after the comment is posted.
Steps to test
- Log in and go to a post
- Copy a link e.g.
https://www.google.com/
- Paste it into a comment on the post and repeatedly and rapidly hit enter until the preview is done
- it should post with the preview, waiting till the preview is ready.
- Repeat with an invalid URL e.g.
https://www.ks3fnj3n9.com
- it should only post when it's been processed for an available preview - you should see the loading indicator that indicates when this is happening.
Estimated Regression Scope
This feature touches a few areas
-
It affects when a user can post by directly stopping the user from posting until progress equal to 100, when a rich-embed is detected. In the worst-case, this could conceivably stop users posting in some edge-case situation.
-
It uses the same progress mechanism as image uploads - I felt it made the most sense as there shouldn't be an overlap of uploading an image and a rich-embed. Regardless, tests one after the other are good.
added scoped labels
- Resolved by Brian Hatchet
approved this merge request
- Developer
Seems to wait to post after load whether it's a valid or invalid link. I don't see the difference in behavior though. Thumbnails are loading on sandbox, but I can see the delay when compared to production.
resolved all threads
- Developer
The difference in behavior is that on production, if you type in
hello here is a link https://www.google.com
and hit enter instantly, the comment text will post, but the preview will appear on a new comment below when it's done.Unfortunately on sandbox there is still no API key for iframely . Moving to blocked.
https://fix-admin-firehose-1658.minds.io/api/v1/newsfeed/preview?url=https%3A%2F%2Fwww.google.com
{"status":403,"error":"Valid api_key is required to access API","meta":{"description":""}}
added scoped label and automatically removed label
181 */ 182 async getPostPreview(message: string) { 183 if ( 184 !message || 185 this.attachment.getMeta().is_rich || 186 !this.attachment.containsRichEmbed(message) 187 ) { 179 188 return; 180 189 } 181 190 182 this.attachment.preview(message, this.detectChanges.bind(this)); 191 this.canPost = false; 192 193 try { 194 this.attachment.preview(message, this.detectChanges.bind(this)); // generate preview. 195 this.attachment.progress.subscribe(progress => { - Owner
Subscription created but never unsubscribed from. Perhaps this subscribe should be at a high level?