Skip to content
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

feat: Download file on mobile viewer on press #2598

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

zatteo
Copy link
Contributor

@zatteo zatteo commented Oct 30, 2024

We want to download file on mobile viewer on press (so when we put the finger on the screen) and not on tap (so when we put the finger on the screen and we release it).

I added a throttle to avoid download multiple time the same file because we can no use anymore 'tapCount' with press which was used to avoid download 3 times the file if we tapped 3 times.

I also moved to useMemo instead of useCallback to support throttle (see facebook/react#19240).

We want to download file on mobile viewer on press (so when we put
the finger on the screen) and not on tap (so when we put the finger
on the screen and we release it).

I added a throttle to avoid download multiple time the same file
because we can no use anymore 'tapCount' with press which was used to
avoid download 3 times the file if we tapped 3 times.

I also moved to useMemo instead of useCallback to support throttle
(see facebook/react#19240).
@zatteo zatteo requested a review from acezard as a code owner October 30, 2024 14:03
Comment on lines +36 to +53
const handleOnClick = useMemo(
() =>
throttle(
async file => {
try {
await downloadFile({ client, file, webviewIntent })
} catch (error) {
showAlert({
message: t('Viewer.error.generic'),
severity: 'error',
variant: 'filled',
icon: false
})
}
},
1000,
{ trailing: false }
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting thanks 👍

@zatteo zatteo merged commit 3c38062 into master Oct 30, 2024
2 checks passed
@zatteo zatteo deleted the feat/open-mobile-viewer-on-press branch October 30, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants