Skip to content

Commit

Permalink
fix: Optimization to display the Shortcut icon
Browse files Browse the repository at this point in the history
We only need this call to useFetchShortcut in order to
get the URL of the shortcut. For the rest of the information
like the icon or iconType, we already have the informations
within the file. So let's use these informations instead of
waiting an http request to resolve.
  • Loading branch information
Crash-- committed Oct 4, 2023
1 parent 2712dfe commit 8f1da9f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/components/ShortcutLink.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints'

export const ShortcutLink = ({ file, desktopSize = 44 }) => {
const client = useClient()
// We only need this call to useFetchShortcut in order to
// get the URL of the shortcut. For the rest of the information
// like the icon or iconType, we already have the informations
// within the file. So let's use these informations instead of
// waiting an http request to resolve.
const { shortcutInfos } = useFetchShortcut(client, file._id)
const { isMobile } = useBreakpoints()
const computedSize = isMobile ? 32 : desktopSize
Expand All @@ -21,11 +26,8 @@ export const ShortcutLink = ({ file, desktopSize = 44 }) => {
* If we don't have iconMimeType, we consider that the icon is a binary svg.
* Otherwise we consider that the icon comes from Iconizer api so it is in base64 directly.
*/
const icon = get(shortcutInfos, 'data.attributes.metadata.icon')
const iconMimeType = get(
shortcutInfos,
'data.attributes.metadata.iconMimeType'
)
const icon = get(file, 'attributes.metadata.icon')
const iconMimeType = get(file, 'attributes.metadata.iconMimeType')

return (
<Link
Expand Down

0 comments on commit 8f1da9f

Please sign in to comment.