Skip to content

[HOLD for payment 2024-04-23] [$500] [Performance] Decouple draft state computation from report #37880

Closed

Description

@muttmuure

Problem

Whenever a user starts to type a new message in Composer, the hasDraft state inside current Report object needs to be updated. The state is later used in LHN to determine if a draft indicator (pencil icon) should be displayed.

Calculations performed by the app to acquire updated hasDraft state are costly. It is caused by the fact that the hasDraft state is a property of a Report object which is then part of the entire list of reports user has access to (14k on testing account). Change of a single report causes list to be invalidated, making costly calculations of getOrderedReportIDs inside SidebarLinksData (component that resides on top of LHN) to run again.

❗ The getOrderedReportIDs calculations might take a few hundred ms, up to a few seconds depending on device and number of reports passed to the function. It is a severe execution overhead, considering how often user starts typing new message during regular conversation.

Solution

The hasDraft state can be decoupled from Report object and stored as an individual entry (or list of entries for many reports) under separate Onyx key. Such a solution should help us avoid invalidating the entire list of reports on every new message being typed, thus not triggering costly re-calculation of getOrderedReportIDs.

In Onyx, the REPORT_DRAFT_COMMENT key exists and serves similar purpose as hasDraft. Considering how hasDraft is used (to display draft indicator) it should not be an issue to re-use REPORT_DRAFT_COMMENT key for such functionality. It is mostly an implementation detail, but this way we are reducing app complexity and state redundancy.

From : @kacper-mikolajczak here

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~012397339f4d656420
  • Upwork Job ID: 1777386978362355712
  • Last Price Increase: 2024-04-20

Activity

  1. mountiny commented on Mar 11, 2024

    @mountiny
    Contributor

    @kacper-mikolajczak can you comment here?

  2. kacper-mikolajczak commented on Mar 11, 2024

    @kacper-mikolajczak
    Contributor

    Yessir! @mountiny

  3. melvin-bot commented on Apr 4, 2024

    @melvin-bot

    Triggered auto assignment to @AndrewGable, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  4. shubham1206agra commented on Apr 8, 2024

    @shubham1206agra
    Contributor

    Please assign me here as C+

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Apr 8, 2024
  6. changed the title [-][Performance] Decouple draft state computation from report[/-] [+][$250] [Performance] Decouple draft state computation from report[/+] on Apr 8, 2024
  7. 15 remaining items

  8. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    NewFeatureSomething to build that is a new item.
    on Apr 20, 2024
  9. melvin-bot commented on Apr 20, 2024

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

  10. mountiny commented on Apr 20, 2024

    @mountiny
    Contributor

    I am fine with the price as it was complex change and it was made before the price change too.

    $500 to @shubham1206agra once ready @dylanexpensify

  11. melvin-bot commented on Apr 23, 2024

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@dylanexpensify)

    • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/1777386978362355712/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. dylanexpensify commented on Apr 23, 2024

    @dylanexpensify
    Contributor

    @shubham1206agra sent invite to apply!

  13. shubham1206agra commented on Apr 24, 2024

    @shubham1206agra
    Contributor
  14. dylanexpensify commented on Apr 29, 2024

    @dylanexpensify
    Contributor

    @shubham1206agra offer sent!

  15. shubham1206agra commented on Apr 29, 2024

    @shubham1206agra
    Contributor

    @dylanexpensify Offer accepted

  16. dylanexpensify commented on Apr 30, 2024

    @dylanexpensify
    Contributor

    Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions