fix(bootstrap-data): always check flashes (#22659)

This commit is contained in:
Ville Brofeldt 2023-01-10 22:14:51 +02:00 committed by GitHub
parent 0b22287ad9
commit 73e53fab7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 5 deletions

View File

@ -388,13 +388,12 @@ def menu_data(user: User) -> Dict[str, Any]:
@cache_manager.cache.memoize(timeout=60)
def common_bootstrap_payload(user: User) -> Dict[str, Any]:
def cached_common_bootstrap_data(user: User) -> Dict[str, Any]:
"""Common data always sent to the client
The function is memoized as the return value only changes based
on configuration and feature flag values.
The function is memoized as the return value only changes when user permissions
or configuration values change.
"""
messages = get_flashed_messages(with_categories=True)
locale = str(get_locale())
# should not expose API TOKEN to frontend
@ -418,7 +417,6 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]:
frontend_config["HAS_GSHEETS_INSTALLED"] = bool(available_specs[GSheetsEngineSpec])
bootstrap_data = {
"flash_messages": messages,
"conf": frontend_config,
"locale": locale,
"language_pack": get_language_pack(locale),
@ -432,6 +430,13 @@ def common_bootstrap_payload(user: User) -> Dict[str, Any]:
return bootstrap_data
def common_bootstrap_payload(user: User) -> Dict[str, Any]:
return {
**(cached_common_bootstrap_data(user)),
"flash_messages": get_flashed_messages(with_categories=True),
}
def get_error_level_from_status_code( # pylint: disable=invalid-name
status: int,
) -> ErrorLevel: