Repository: plotly/dash
File: dash/dash-renderer/src/components/error/menu/VersionInfo.react.js (JavaScript)

Code before:
                        localStorage.setItem(
                            'cachedNewDashVersionLink',
                            body.link
                        );
                        localStorage.setItem('lastFetched', Date.now());
                    } catch (e) {
                        // Ignore errors if localStorage is not available
                    }
                    return body;
                } else {
                    return {};
                }
            })
            .catch(() => {
                return {};
            });
    }
}

function shouldRequestDashVersion(config) {
    let showNotificationsLocalStorage, showNotifications, lastFetched;
    try {
        showNotificationsLocalStorage =
            localStorage.getItem('showNotifications');

        showNotifications = config.disable_version_check
            ? false
            : showNotificationsLocalStorage !== 'false';
        lastFetched = localStorage.getItem('lastFetched');
    } catch (e) {
        // If localStorage is not available, return false
        return false;
    }
    return (
        showNotifications &&
        (!lastFetched || Date.now() - Number(lastFetched) > DAY_IN_MS)
    );
}

function shouldShowUpgradeNotification(
    currentDashVersion,
    newDashVersion,
    config
) {
    let showNotificationsLocalStorage, lastDismissed, lastDismissedVersion;
    try {
        showNotificationsLocalStorage =
            localStorage.getItem('showNotifications');
        lastDismissed = localStorage.getItem('lastDismissed');
        lastDismissedVersion = localStorage.getItem('lastDismissedVersion');
    } catch (e) {

Review comment (bug):
Can we move that check to the DebugMenu render like: `{!config.disable_version_check && <VersionInfo />}` ?

Code after:
                        localStorage.setItem(
                            'cachedNewDashVersionLink',
                            body.link
                        );
                        localStorage.setItem('lastFetched', Date.now());
                    } catch (e) {
                        // Ignore errors if localStorage is not available
                    }
                    return body;
                } else {
                    return {};
                }
            })
            .catch(() => {
                return {};
            });
    }
}

function shouldRequestDashVersion(config) {
    // If version check is disabled, return false to avoid
    // checking localStorage unnecessarily
    if (config.disable_version_check) {
        return false;
    }
    let showNotifications, lastFetched;
    try {
        showNotifications =
            localStorage.getItem('showNotifications') !== 'false';
        lastFetched = localStorage.getItem('lastFetched');
    } catch (e) {
        // If localStorage is not available, return false
        return false;
    }
    return (
        showNotifications &&
        (!lastFetched || Date.now() - Number(lastFetched) > DAY_IN_MS)
    );
}

function shouldShowUpgradeNotification(
    currentDashVersion,
    newDashVersion,
    config
) {
    // If version check is disabled, return false to avoid
    // checking localStorage unnecessarily
    if (config.disable_version_check) {
        return false;
    }
    let showNotifications, lastDismissed, lastDismissedVersion;