Changed auth_type to an i32 to make it easier to pass across the FFI boundary. Also changed a return type to a String for the same reason.
Depends on D4933
Differential D4934
[native] change params and types to satisfy cxx requirements varun on Aug 23 2022, 10:43 PM. Authored by Tags None Referenced Files
Details Changed auth_type to an i32 to make it easier to pass across the FFI boundary. Also changed a return type to a String for the same reason. Depends on D4933 cargo build
Diff Detail
Event TimelineComment Actions
Is it a good practice to use i32 instead of enum? How hard is it to pass an enum?
Comment Actions It's not a great practice but it's hard to pass an enum. If the enum is defined in the ffi module, the compiler complains: non-primitive cast: `ffi::AuthType` as `i32` an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object And if I try to define it in the Rust library, the compiler complains about passing opaque Rust types by value. I can explore a better solution and revisit this later, if that works for you.
Comment Actions Yeah, a small research sounds like a good idea. The safer we make this code, the less problems we will have in the future. A quick search gave me this https://rust-lang.github.io/unsafe-code-guidelines/layout/enums.html#repr-annotations-accepted-on-enums - not sure, but it might be helpful.
|
We definitely should return something from this lambda since otherwise it is useless to assign it to variable.
If we find that we don't have permissions then just calling await this.requestAndroidNotificationsPermission(); would result in a prompt asking for notifications permissions. However if the user grants those permissions then hasPermissions is still falsy (since promise returned nothing), so deviceToken will be set to null. Nevertheless permissions are actually granted byt the OS, so the state on the device and keyserver would heal itself on next render.
This differential fixes this case so that if user grants permissions correct state is achieved immediately without need for additional re-render to heal the state.