import React, { Component } from 'react'; import { withTranslation, Trans } from 'react-i18next'; import { Paper, Alert, AlertTitle, Button, Link } from '@mui/material'; import MediaQuery from 'react-responsive'; import { getHost } from '../utils'; class UnsafeAlert extends Component { constructor(props) { super(props); this.state = { show: true, }; } // To do. Read from Coordinators state Obj. safe_urls = [ 'robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion', 'robotestagw3dcxmd66r4rgksb4nmmr43fh77bzn2ia2eucduyeafnyd.onion', 'robodevs7ixniseezbv7uryxhamtz3hvcelzfwpx3rvoipttjomrmpqd.onion', 'robosats.i2p', 'r7r4sckft6ptmk4r2jajiuqbowqyxiwsle4iyg4fijtoordc6z7a.b32.i2p', ]; checkClient() { const http = new XMLHttpRequest(); const host = getHost(); const unsafeClient = !this.safe_urls.includes(host); try { http.open('HEAD', `${location.protocol}//${host}/selfhosted`, false); http.send(); this.props.setSettings({ ...this.props.settings, host, unsafeClient, selfhostedClient: http.status === 200, }); } catch { this.props.setSettings({ ...this.props.settings, host, unsafeClient, selfhostedClient: false, }); } } componentDidMount() { this.checkClient(); } render() { const { t } = this.props; // If alert is hidden return null if (!this.state.show) { return null; } // Show selfhosted notice else if (this.props.settings.selfhostedClient) { return (