Skip to content

Commit

Permalink
fix: content not loading on certain occassion
Browse files Browse the repository at this point in the history
utilize try catch block to ensure that the content is passed to the ember app after ifram is loaded
  • Loading branch information
thealpha93 committed Jun 25, 2021
1 parent 6552f23 commit 21204b8
Show file tree
Hide file tree
Showing 2 changed files with 3,600 additions and 3,644 deletions.
12 changes: 9 additions & 3 deletions pages/posts/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,23 @@ export default function Write({ post_Id }) {

if (userCookie) {
setPostId(currentPostId);
getPostById(currentPostId);
try {
// errors on refresh
// console.log(iframeRef.current.contentWindow);
// !START
// *IMPORTANT: Don't remove the below block of code
const iframeElement = iframeRef.current;
iframeElement.contentWindow.innerWidth;
// *IMPORTANT: It's the reason the control goes to the catch block on refresh
// !END

iframeElement.onload = function () {

iframeRef.current.onload = function () {
if (currentPostId) {
getPostById(currentPostId);
}
};
} catch (error) {
console.log("error blaaaah==>", error)
getPostById(currentPostId);
}
}
Expand Down
Loading

0 comments on commit 21204b8

Please sign in to comment.