HomePhabricator
Diffusion Comm ec51474a3231

[web] Fix bug where image appears broken when creating thread with media message

Description

[web] Fix bug where image appears broken when creating thread with media message

Summary:
Linear issue: ENG-3673

What was happening here in Redux is that the second sendMultimediaMessageActionTypes.started action was overwriting the actualized URI that was set by the second updateMultimediaMessageMediaActionType, which is responsible for replacing the local blob URI with the actualized URI after the preload completes.

Once the preload completes, we unload the blob URI, which is why a [?] was appearing in the UI. We should not use the blob URI after the preload of the actualized URI is completed.

The reason we were using the blob URI was that when sendMultimediaMessage was first called, the preload was not completed yet. But sendMultimediaMessage has to wait for the thread creation to complete, and once the thread creation was complete, the preload had already finished and the blob URI had been unloaded. But sendMultimediaMessage was still using the old RawMessageInfo that had the local blob URI.

This diff fixes the behavior by making sure that sendMultimediaMessage pulls the latest version of the RawMessageInfo from Redux after the thread creation completes.

Test Plan: I created a new thread in my local environment with an image, and made sure to do it quickly by hitting the Enter button on the keyboard repeatedly. It's critical that the thread creation proceed before the image upload completes for the test to work. Before this diff, it led to the issue in the Linear task. After this diff, the issue did not occur.

Reviewers: tomek, atul, bartek

Reviewed By: tomek

Differential Revision: https://phab.comm.dev/D7416