Page MenuHomePhabricator

[lib] Factor out useStaffAlert()
ClosedPublic

Authored by angelika on Fri, Oct 25, 3:13 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 25, 5:18 PM
Unknown Object (File)
Fri, Oct 25, 5:17 PM
Unknown Object (File)
Fri, Oct 25, 5:12 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.