Page MenuHomePhabricator

[lib] Factor out useStaffAlert()
ClosedPublic

Authored by angelika on Oct 25 2024, 3:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 25, 10:19 AM
Unknown Object (File)
Mon, Nov 25, 5:44 AM
Unknown Object (File)
Sat, Nov 23, 6:35 AM
Unknown Object (File)
Sat, Nov 23, 5:29 AM
Unknown Object (File)
Sat, Nov 23, 5:10 AM
Unknown Object (File)
Sun, Nov 17, 5:29 AM
Unknown Object (File)
Wed, Nov 13, 4:04 AM
Unknown Object (File)
Sun, Nov 10, 11:05 PM
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.Mon, Oct 28, 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.