Skip to content

Commit

Permalink
Fix issue where images wouldn't load if just posted
Browse files Browse the repository at this point in the history
  • Loading branch information
Macludde committed Dec 16, 2021
1 parent 1d89994 commit fcb879c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/pages/Feed/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,21 @@ const Post: React.FC<PostProps> = ({ post, hideComments, children }) => {
post.type === 'file' ||
post.type === undefined
) {
getDownloadURL(
ref(storage, `posts/${post.author}/${post.id}`)
).then((url) => setContentURL(url))
const getURL = async (level: number) => {
if (level > 5) return
try {
const url = await getDownloadURL(
ref(storage, `posts/${post.author}/${post.id}`)
)
setContentURL(url)
} catch (error) {
setContentURL(null)
setTimeout(() => {
getURL(level + 1)
}, 200)
}
}
getURL(0)
}
}, [post.id, post.author, post.type])

Expand Down

0 comments on commit fcb879c

Please sign in to comment.