/* * Wire * Copyright (C) 2021 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import React, {useEffect} from 'react'; import cx from 'classnames'; import {Runtime} from '@wireapp/commons'; import * as Icon from 'Components/Icon'; import {t} from 'Util/LocalizerUtil'; import {afterRender} from 'Util/util'; import {closeWarning, useWarningsState} from './WarningsState'; import {CONFIG, TYPE} from './WarningsTypes'; import {Config} from '../../Config'; interface WarningProps { onRefresh: () => void; } const WarningsContainer: React.FC = ({onRefresh}) => { const name = useWarningsState(state => state.name); const warnings = useWarningsState(state => state.warnings); const type = TYPE; const visibleWarning = warnings[warnings.length - 1]; const warningDimmed = warnings.some(warning => CONFIG.DIMMED_MODES.includes(warning)); useEffect(() => { const visibleWarning = warnings[warnings.length - 1]; const isConnectivityRecovery = visibleWarning === TYPE.CONNECTIVITY_RECOVERY; const hasOffset = warnings.length > 0 && !isConnectivityRecovery; const isMiniMode = CONFIG.MINI_MODES.includes(visibleWarning); const app = document.querySelector('#app'); if (app) { app.classList.toggle('app--small-offset', hasOffset && isMiniMode); app.classList.toggle('app--large-offset', hasOffset && !isMiniMode); } afterRender(() => window.dispatchEvent(new Event('resize'))); }, [warnings]); const brandName = Config.getConfig().BRAND_NAME; const URL = Config.getConfig().URL; const closeButton = ( )} ); }; export {WarningsContainer};