Page MenuHomePhabricator

[lib] Factor out useStaffAlert()
ClosedPublic

Authored by angelika on Fri, Oct 25, 3:13 PM.
Tags
None
Referenced Files
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
Unknown Object (File)
Sun, Nov 10, 1:10 PM
Unknown Object (File)
Sat, Nov 9, 10:42 AM
Unknown Object (File)
Sat, Nov 9, 10:42 AM
Unknown Object (File)
Thu, Nov 7, 10:43 PM
Unknown Object (File)
Mon, Nov 4, 1:38 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
Branch
graszka22/ENG-9807
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Thanks for doing this!

lib/shared/staff-utils.js
2

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

52–57

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.