Page MenuHomePhabricator

[lib] Factor out useStaffAlert()
ClosedPublic

Authored by angelika on Oct 25 2024, 3:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 19, 9:39 AM
Unknown Object (File)
Wed, Dec 18, 9:21 AM
Unknown Object (File)
Sun, Dec 15, 7:56 PM
Unknown Object (File)
Sun, Dec 15, 7:56 PM
Unknown Object (File)
Sun, Dec 15, 7:56 PM
Unknown Object (File)
Sun, Dec 15, 7:55 PM
Unknown Object (File)
Sun, Dec 15, 7:49 PM
Unknown Object (File)
Sun, Dec 15, 3:36 AM
Subscribers

Details

Summary

We want to show staff alerts also in other places in the app so I factored it out to a hook in another file.
Related to: https://linear.app/comm/issue/ENG-9807/add-staff-alert-for-decryption-related-errors

Test Plan

Run the app and see if alerts are shown.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Thanks for doing this!

lib/shared/staff-utils.js
2 ↗(On Diff #45393)

Nit: please maintain the newline after the // @flow declaration

52–57 ↗(On Diff #45393)

Not sure how useful this one is... I would just use JSON.stringify at the callsite instead of requiring this generic utility to be aware of DMOperation

This revision is now accepted and ready to land.Oct 28 2024, 3:49 AM

Remove showOperationAlertToStaff

This implementation has a performance consequence - in the original implementation, we were only stringifying when an alert was shown. Now we're stringifying the object even for users who will never see an alert. We could consider keeping the JSON.stringify inside showAlertToStaff, but I'm not sure if it is really that important.

This implementation has a performance consequence - in the original implementation, we were only stringifying when an alert was shown. Now we're stringifying the object even for users who will never see an alert. We could consider keeping the JSON.stringify inside showAlertToStaff, but I'm not sure if it is really that important.

I would guess this perf impact is minimal

var startTime = performance.now()

for(var i = 0; i < 1000; ++i) {
JSON.stringify({"asdfasdf": "fhsdjfhsjdhf", "fjksdfhksdhfj": 234234})
}
var endTime = performance.now()

console.log(`Call to doSomething took ${endTime - startTime} milliseconds`)
VM529:8 Call to doSomething took 0.5 milliseconds

I guess we can live with it ;) I'm landing this.

This revision was automatically updated to reflect the committed changes.