deltachat / deltachat-android

Email-based instant messaging for Android.
GNU General Public License v3.0
1.15k stars 148 forks source link

fix: check draft.isOk() instead of comparing to null #3432

Closed link2xt closed 4 days ago

link2xt commented 1 week ago

dcContext.getDraft() never returns null.

github-actions[bot] commented 1 week ago

To test the changes in this pull request, install this apk: 📦 app-preview.apk

adbenitez commented 5 days ago

maybe the correct fix would be to return null in getDraft, having to ask for isOk() is harder to remember than a more visible NullPointerException

link2xt commented 5 days ago

maybe the correct fix would be to return null in getDraft, having to ask for isOk() is harder to remember than a more visible NullPointerException

This is done in getProviderFromEmailWithDns. But getMsg does the same as getDraft and we check for isOk everywhere. Good thing about wrapping NULL is that if you forget to check, you will get no-op calls because FFI calls check for NULL and "ignore careless call ..." silently. This is probably better than crashing the app.