question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove `setTimeout` usage in AttachmentPicker/index.native.js

See original GitHub issue

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Expected Result:

The Attachment Picker modal should work correctly without the need of setTimeout

Actual Result:

setTimeout is needed because on iOS the Gallery/Camera is immediately dismissed when the Attachment bottom docked modal closes

Details

This is a follow up on https://github.com/Expensify/Expensify.cash/pull/2656#discussion_r624113073 It can potentially be resolved by updating the attachment related libraries handled in this ticket: #2531

Action Performed:

  1. Open a chat
  2. Select (+) button to add an attachment
  3. Select gallery
  4. Sometimes the gallery would open and immediately close or not open at all

Workaround:

Added a brief timeout so that the Camera/Gallery is only opened a 1-2 frames after the Attachment Picker modal closes

Platform:

Where is this issue occurring?

  • Web
  • ✅ iOS
  • Android
  • Desktop App
  • Mobile Web

Version Number: 1.0.38-1 Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos: Any additional supporting documentation Expensify/Expensify Issue URL:

View all open jobs on Upwork

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:29 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
tgolencommented, May 27, 2021

Yeah, let’s put this on HOLD until that library is updated. Good call.

1reaction
kidrocacommented, May 27, 2021

Sorry but there’s some big misunderstanding here. There’s nothing that can be done for this ticket ATM. And there’s no bug that needs fixing - I was asked to open this task as a reminder to remove the setTimeout call at some point in the future when that’s possible

https://github.com/Expensify/Expensify.cash/pull/2656#discussion_r626854415

@tgolen Could you please create a follow-up GH issue to remove the setTimeout once the libraries are updated and this is no longer a problem?

Currently it’s not possible it will lead to a bug preventing image picking I don’t see any way to address this right now. The best thing to do IMO is to wait the other ticket that updates the image picker library and see if the setTimeout can be removed then

@Christinadobrzyn I can’t accept the Upwork invite as I don’t see a way to complete this task ATM

Read more comments on GitHub >

github_iconTop Results From Across the Web

clearTimeout() - Web APIs - MDN Web Docs
The global clearTimeout() method cancels a timeout previously established by calling setTimeout().
Read more >
How to clear a settimeout in react - Stack Overflow
The best way in React to clear Timeouts and Intervals are by assinging ref to your interval/timeout functions which works flawlessly and use...
Read more >
Window clearTimeout() Method - W3Schools
To clear a timeout, use the id returned from setTimeout():. myTimeout = setTimeout(function, milliseconds);. Then you can to stop the execution by calling ......
Read more >
setTimeout JavaScript Function: Guide with Examples - SitePoint
The native JavaScript setTimeout function calls a function or executes ... which can be used in conjunction with clearTimeout to cancel the ...
Read more >
Timer Mocks - Jest
The native timer functions (i.e., setTimeout(), setInterval(), clearTimeout(), clearInterval()) are less than ideal for a testing ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found