zulip / zulip-mobile

Zulip mobile apps for Android and iOS.
https://zulip.com/apps/
Apache License 2.0
1.3k stars 655 forks source link

TranslationProvider: Fix crash on login, from non-null-FL invariant #5865

Closed chrisbobbe closed 6 months ago

chrisbobbe commented 6 months ago

Sentry is reminding us that we forgot to check if the active account has server data. Adding this check fixes a crash when zulipFeatureLevel is null because of not having server data right after login.

gnprice commented 6 months ago

Thanks!

I was a bit surprised we don't have the feature level right after login — after all, we just learned it from the server settings. But reading getZulipFeatureLevel and following references, this comment (in getServerVersion) explains it:

  //   Oh, and there's one other case where an Account record will lack this
  //   data: immediately after login, before we complete the first initial
  //   fetch.  That's fixable, though: we already have the version from
  //   server_settings when we enter the login flow, so we just need to
  //   remember that value and stick it in the initial Account record.

In zulip-flutter, we already use that information to have a feature level from the beginning right after login. (OTOH we don't yet update it on register, as zulip-mobile does; that's https://github.com/zulip/zulip-flutter/issues/458 .)


Anyway, this all LGTM — merging.