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

Fix multiple download issues on Mobile Safari and desktop versions. #37131

Conversation

wildan-m
Copy link
Contributor

@wildan-m wildan-m commented Feb 23, 2024

@ishpaul777 @techievivek

Details

Fix multiple download issues on Mobile Safari and desktop versions.

Fixed Issues

$ #35189
PROPOSAL: #35189 (comment)

Tests

Pre-requisite: The user must have sent at least 2 files in the chat. The file types should not be supported for preview (e.g. docx, csv, .zip)

Mobile Safari

  1. Go to the chat where you sent the two files
  2. Tap the download button next to a file name
  3. Verify that Mobile safari will open new tab and process the download in that new tab

Other Platforms

  1. Go to the chat where you sent the two files
  2. Tap the download button next to a file name
  3. Before the first file is downloaded, press the download button of the second file
  4. Ensure that all clicked files will be downloaded.
  • Verify that no errors appear in the JS console

Offline tests

Users should not be able to download files when offline; the download button should be disabled.

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
GMT20240223-140921_Clip_Wildan.M.s.Clip.02_23_2024.mp4
Android: mWeb Chrome
GMT20240223-140632_Clip_Wildan.M.s.Clip.02_23_2024.mp4
iOS: Native
GMT20240223-134318_Clip_Wildan.M.s.Clip.02_23_2024.mp4
iOS: mWeb Safari
GMT20240223-134522_Clip_Wildan.M.s.Clip.02_23_2024.mp4
MacOS: Chrome / Safari
GMT20240223-100835_Clip_Wildan.M.s.Clip.02_23_2024-2.mp4
MacOS: Desktop
GMT20240223-100432_Clip_Wildan.M.s.Clip.02_23_2024.mp4

@wildan-m wildan-m marked this pull request as ready for review February 23, 2024 14:16
@wildan-m wildan-m requested a review from a team as a code owner February 23, 2024 14:16
@melvin-bot melvin-bot bot removed the request for review from a team February 23, 2024 14:16
Copy link

melvin-bot bot commented Feb 23, 2024

@ishpaul777 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@@ -0,0 +1,243 @@
import type {DownloadItem, Event, SaveDialogOptions, Session, WebContents} from 'electron';
Copy link
Contributor

@ishpaul777 ishpaul777 Feb 23, 2024

Choose a reason for hiding this comment

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

what does this file does? Can you write TLDR for code for some context ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishpaul777 the comment is bellow. Should we move it to the top?

/**
* This file is a ported version of the `electron-dl` package.
* It provides a download manager for Electron applications.
* The `electron-dl` package simplifies the process of downloading files in Electron apps
* by providing a high-level API and handling various download-related tasks.
* This file contains the implementation of the Electron Download Manager.
*/

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant how this works internally what does each function does, also add jsDocs for functions in the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishpaul777 I've revised the code to include additional comments from the original author and added new comments for new functions.

The changes made involve converting the code from JavaScript to TypeScript, replacing 'interface' with 'type', and eliminating dependencies on external libraries such as unused-filename, pupa, and ext-name.

I believe it is beneficial to keep the currently unused functionalities for potential future requirements, as it minimizes re-testing of the replicated package and facilitates referencing the original package in case of similar issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it is beneficial to keep the currently unused functionalities for potential future requirements

following the YAGNI principle we should only keep the functionalities that are necessary for the current requirement we can always add them back in future when required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishpaul777 the PR has been updated with removal of unused functionalities and type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishpaul777 any other feedback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ishpaul777 @techievivek friendly bump

@wildan-m
Copy link
Contributor Author

wildan-m commented May 3, 2024

Requested more changes.

Sure, I hope we can achieve a faster turnaround time.

@allroundexperts
Copy link
Contributor

allroundexperts commented May 5, 2024

Sure, I hope we can achieve a faster turnaround time.

@wildan-m I made some more comments. If done correctly, I think this would be the last one. Thank you for your patience with this. I fully understand and acknowledge the hard work you're putting into this. I'll try my best to provide feedback as fast as possible.

};

electronDownload(item.win, item.url, options);
item.win.webContents.session.on('will-download', listener);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not save the listener in a variable? Would be a little more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Did you mean to create the listener in a separate function?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, use it directly like:

            item.win.webContents.session.on('will-download', () => {
                // code for the listener
            });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how can we perform cleanup without the listener variable?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, forgot about that. Never mind then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please do not approve yet. I have noticed that the file has been renamed to download.html, and I am investigating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please do not approve yet. I have noticed that the file has been renamed to download.html, and I am investigating it.

@allroundexperts ok it's fixed, please help review the recent changes

const downloadItemProcessor = (item: DownloadItem): Promise<void> =>
new Promise((resolve, reject) => {
item.win.webContents.downloadURL(item.url);

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we set a timeout here as well and reject the promise if the listener does not get called within that timeout period?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts What is the expected behavior if the loading spinner timeout is reached? Should it stop downloading or continue downloading even after the spinner has stopped? Rejecting here will process the next item, resulting in some files not being downloaded due to the original issue in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if I understand your question. In the processor, if the listener is not called after a certain amount of time, then that really means something is wrong. Isn't that the case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

then that really means something is wrong

@allroundexperts Not always. It can also indicate that the download may take longer than usual, possibly due to network speed/latency or attachment size.

Currently, we only use setTimeout in fileDownload to ensure that the loading spinner stops, but it doesn't halt the actual download process.

If we set a timeout in the processor, then the next item will be processed. However, if the user takes no action, the file save dialog will remain open, preventing the next processed item from downloading, It's a similar situation when we do not implement this PR, but with timeout.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we are not on the same page here. My understanding is that item.win.webContents.session.on('will-download', listener); would be called immediately on download start. You're suggesting that it would be called once the download completes?

Copy link
Contributor

Choose a reason for hiding this comment

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

@wildan-m You should remove the timeout if listener gets called. That was the whole point of adding it.

Copy link
Contributor

Choose a reason for hiding this comment

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

   const downloadItemProcessor = (item: DownloadItem): Promise<void> =>
        new Promise((resolve, reject) => {
            item.win.webContents.downloadURL(item.url);

            // Add a timeout to resolve the promise after 5 seconds
            const timeout = setTimeout(() => {
                item.win.webContents.session.removeListener('will-download', listener);
                resolve();
            }, 5000);

            const listener = (event: Electron.Event, electronDownloadItem: Electron.DownloadItem) => {
               clearTimeout(timeout)
                .................

                item.win.webContents.send(ELECTRON_EVENTS.DOWNLOAD_STARTED, {url: item.url});
            };

            item.win.webContents.session.on('will-download', listener);

        });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts clearing the timeout will not resolve the issue I mentioned earlier in the video.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tried it? Why doesn't it solve the issue? Does the listener not get called even after 5s?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts I apologize for the incorrect assumption. I thought that will-download would not be called when the saveAs dialog opens. I have made the updates, please review them.

return new Promise((resolve) => {
// This sets a timeout that will resolve the promise after 5 seconds to prevent indefinite hanging
const downloadTimeout = setTimeout(() => {
resolve();
Copy link
Contributor

Choose a reason for hiding this comment

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

We should reject here and let the user know that something went wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts how should it look? Native fileDownload use RN alert to display errors/success, but it's not implemented on the web/desktop. I believe this could be considered a feature request.

resolve();
}, CONST.DOWNLOADS_TIMEOUT);

window.electron.on(ELECTRON_EVENTS.DOWNLOAD_STARTED, (...args: unknown[]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we've discussed this a lot, but I don't think that relying on DOWNLOAD_STARTED event would work here. If the queue is already processing a large file, we'll always hit the downloadTimeout. A better way would be to listen for a new event called DOWNLOAD_QUEUED and emit it whenever the download item is queued.

Copy link
Contributor Author

@wildan-m wildan-m May 13, 2024

Choose a reason for hiding this comment

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

@allroundexperts Another point to consider why it's better to start the loader on onPress instead of DOWNLOAD_QUEUED is that the spinner is used to prevent rapid clicks on the same download link. If we start the loader when it's queued, although minimal delay, it might allow the user to download the same file multiple times.

Have a look at this video:

Kapture.2024-05-13.at.08.48.47.mp4

Please re-consider.

applied changes
diff --git a/desktop/ELECTRON_EVENTS.ts b/desktop/ELECTRON_EVENTS.ts
index cb0b05f097..fd0952b083 100644
--- a/desktop/ELECTRON_EVENTS.ts
+++ b/desktop/ELECTRON_EVENTS.ts
@@ -11,6 +11,7 @@ const ELECTRON_EVENTS = {
     UPDATE_DOWNLOADED: 'update-downloaded',
     DOWNLOAD: 'download',
     DOWNLOAD_STARTED: 'download-started',
+    DOWNLOAD_QUEUED: 'download-queued',
     SILENT_UPDATE: 'silent-update',
 } as const;
 
diff --git a/desktop/contextBridge.ts b/desktop/contextBridge.ts
index e9c61e6953..5aadbc4651 100644
--- a/desktop/contextBridge.ts
+++ b/desktop/contextBridge.ts
@@ -26,6 +26,7 @@ const WHITELIST_CHANNELS_MAIN_TO_RENDERER = [
     ELECTRON_EVENTS.FOCUS,
     ELECTRON_EVENTS.BLUR,
     ELECTRON_EVENTS.DOWNLOAD_STARTED,
+    ELECTRON_EVENTS.DOWNLOAD_QUEUED,
 ] as const;
 
 const getErrorMessage = (channel: string): string => `Electron context bridge cannot be used with channel '${channel}'`;
diff --git a/desktop/createDownloadQueue.ts b/desktop/createDownloadQueue.ts
index 29ce595fc5..c32fa5ad9f 100644
--- a/desktop/createDownloadQueue.ts
+++ b/desktop/createDownloadQueue.ts
@@ -108,6 +108,8 @@ const createDownloadQueue = () => {
 
     const enqueueDownloadItem = (item: DownloadItem): void => {
         queue.enqueue(item);
+        item.win.webContents.send(ELECTRON_EVENTS.DOWNLOAD_QUEUED, {url: item.url});
+
     };
     return {enqueueDownloadItem, dequeueDownloadItem: queue.dequeue};
 };
diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx
index d6bdd241dc..ad51aa8c5d 100644
--- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx
+++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx
@@ -48,8 +48,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow
                         if (isDownloading || isOffline) {
                             return;
                         }
-                        Download.setDownload(sourceID, true);
-                        fileDownload(sourceURLWithAuth, displayName, '', Browser.isMobileSafari()).then(() => Download.setDownload(sourceID, false));
+                        fileDownload(sourceURLWithAuth, displayName, '', Browser.isMobileSafari(), () => { Download.setDownload(sourceID, true) }).then(() => Download.setDownload(sourceID, false));
                     }}
                     onPressIn={onPressIn}
                     onPressOut={onPressOut}
diff --git a/src/libs/fileDownload/index.desktop.ts b/src/libs/fileDownload/index.desktop.ts
index 90faa1285b..8e1c213883 100644
--- a/src/libs/fileDownload/index.desktop.ts
+++ b/src/libs/fileDownload/index.desktop.ts
@@ -6,7 +6,7 @@ import type {FileDownload} from './types';
 /**
  * The function downloads an attachment on desktop platforms.
  */
-const fileDownload: FileDownload = (url, fileName) => {
+const fileDownload: FileDownload = (url, fileName, successMessage = '', shouldOpenExternalLink = false, startDownload = () => {}) => {
     const options: Options = {
         filename: fileName,
         saveAs: true,
@@ -18,6 +18,17 @@ const fileDownload: FileDownload = (url, fileName) => {
             resolve();
         }, CONST.DOWNLOADS_TIMEOUT);
 
+        window.electron.on(ELECTRON_EVENTS.DOWNLOAD_QUEUED, (...args: unknown[]) => {
+            const arg = Array.isArray(args) ? args[0] : null;
+            const eventUrl = arg && typeof arg === 'object' && 'url' in arg ? arg.url : null;
+
+            // This event is triggered for all active download instances. We intentionally keep other promises waiting.
+            // Early resolution or rejection of other promises could prematurely stop the loading spinner or prevent the promise from being resolved.
+            if (eventUrl === url) {
+                startDownload();
+            }
+        });
+
         window.electron.on(ELECTRON_EVENTS.DOWNLOAD_STARTED, (...args: unknown[]) => {
             const arg = Array.isArray(args) ? args[0] : null;
             const eventUrl = arg && typeof arg === 'object' && 'url' in arg ? arg.url : null;
diff --git a/src/libs/fileDownload/types.ts b/src/libs/fileDownload/types.ts
index fcc210c1c4..99763dfc42 100644
--- a/src/libs/fileDownload/types.ts
+++ b/src/libs/fileDownload/types.ts
@@ -1,6 +1,6 @@
 import type {Asset} from 'react-native-image-picker';
 
-type FileDownload = (url: string, fileName?: string, successMessage?: string, shouldOpenExternalLink?: boolean) => Promise<void>;
+type FileDownload = (url: string, fileName?: string, successMessage?: string, shouldOpenExternalLink?: boolean, startDownload?: () => void) => Promise<void>;
 
 type ImageResolution = {width: number; height: number};
 type GetImageResolution = (url: File | Asset) => Promise<ImageResolution>;

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just disable it once clicked, then show a loader once the DOWNLOAD_QUEUED event is received?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts may I ask why we should initiate the loading spinner within the DOWNLOAD_QUEUE instead of placing it in the onPress function? What major advantage does this approach offer?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's any great advantage. It's just that it seems like a more event driven approach. Let's skip that if you feel too strongly about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@allroundexperts I would like to keep the loading spinner and disable logic one together to minimize overhead. Therefore, the pending changes are to change DOWNLOAD_STARTED to DOWNLOAD_COMPLETED, DOWNLOAD_FAILED, and DOWNLOAD_CANCELED. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New changes have been applied

@allroundexperts
Copy link
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: Native

Android build not working

Android: mWeb Chrome
Screen.Recording.2024-05-21.at.8.56.25.PM.mov
iOS: Native
Screen.Recording.2024-05-21.at.8.48.49.PM.mov
iOS: mWeb Safari
Screen.Recording.2024-05-21.at.8.42.55.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2024-05-21.at.8.36.52.PM.mov
MacOS: Desktop
Screen.Recording.2024-05-21.at.8.39.26.PM.mov

Copy link
Contributor

@allroundexperts allroundexperts left a comment

Choose a reason for hiding this comment

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

Works great. Thanks for your patience and hard work @wildan-m!

@melvin-bot melvin-bot bot requested a review from techievivek May 21, 2024 16:12
@Expensify Expensify deleted a comment from ishpaul777 May 22, 2024
Copy link
Contributor

@techievivek techievivek left a comment

Choose a reason for hiding this comment

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

Great work 🚀, Approving but can't merge since we are having merge freeze on App and several other repos.

@wildan-m
Copy link
Contributor Author

@techievivek when will the merge freeze end?

@techievivek
Copy link
Contributor

Thank you for your patience and hard work. We are good to merge now.

@techievivek techievivek merged commit 6be3455 into Expensify:main May 28, 2024
16 of 17 checks passed
@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/techievivek in version: 1.4.77-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.77-11 🚀

platform result
🤖 android 🤖 failure ❌
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/puneetlath in version: 1.4.77-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

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.

5 participants