From 26be5cf8f9a7d0b6df239ede5ed6bdaafd54c12f Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Wed, 1 May 2024 14:37:35 -0700 Subject: [PATCH] TranslationProvider: Fix crash on login, from non-null-FL invariant 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. --- src/boot/TranslationProvider.js | 2 ++ src/boot/streamChannelRenamesMap.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/boot/TranslationProvider.js b/src/boot/TranslationProvider.js index fac87a1aac..0951eeaf90 100644 --- a/src/boot/TranslationProvider.js +++ b/src/boot/TranslationProvider.js @@ -15,6 +15,7 @@ import { streamChannelRenameFeatureLevel, streamChannelRenamesMap, } from './streamChannelRenamesMap'; +import { getHaveServerData } from '../haveServerDataSelectors'; // $FlowFixMe[incompatible-type] could put a well-typed mock value here, to help write tests export const TranslationContext: React.Context = React.createContext(undefined); @@ -103,6 +104,7 @@ export default function TranslationProvider(props: Props): React.Node { // TODO(server-9.0) remove "stream" terminology const effectiveMessagesByLanguage = activeAccountState == null + || !getHaveServerData(activeAccountState) || getZulipFeatureLevel(activeAccountState) >= streamChannelRenameFeatureLevel ? messagesByLanguageRenamed : messagesByLanguage; diff --git a/src/boot/streamChannelRenamesMap.js b/src/boot/streamChannelRenamesMap.js index cdc02231f4..78acb6b43c 100644 --- a/src/boot/streamChannelRenamesMap.js +++ b/src/boot/streamChannelRenamesMap.js @@ -4,8 +4,9 @@ * The feature level at which we want to say "channel" instead of "stream". * * Outside a per-account context, check the feature level of the active - * account, if there is one. If there isn't an active account, just choose - * "channel" terminology unconditionally. + * account, if there is one and it has server data. If there isn't an active + * account or it doesn't have server data, just choose "channel" terminology + * unconditionally. */ // TODO(server-9.0) simplify away // https://chat.zulip.org/api/changelog#changes-in-zulip-90