import { connect } from 'react-redux'; import React from 'react'; import PropTypes from 'prop-types'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import { Link } from 'react-router-dom'; import { invitesEnabled, repository, source_url, version } from 'mastodon/initial_state'; import { logOut } from 'mastodon/utils/log_out'; import { openModal } from 'mastodon/actions/modal'; import { isStaff } from '../../../initial_state'; const messages = defineMessages({ logoutMessage: { id: 'confirmations.logout.message', defaultMessage: 'Are you sure you want to log out?' }, logoutConfirm: { id: 'confirmations.logout.confirm', defaultMessage: 'Log out' }, }); const mapDispatchToProps = (dispatch, { intl }) => ({ onLogout() { dispatch(openModal('CONFIRM', { message : intl.formatMessage(messages.logoutMessage), confirm : intl.formatMessage(messages.logoutConfirm), onConfirm: () => logOut(), })); }, }); // const themeIsDark = true; // const displaythemetoggler = true; export default @injectIntl @connect(null, mapDispatchToProps) class LinkFooter extends React.PureComponent { static propTypes = { enableChristmasSnow: PropTypes.bool, snowActive : PropTypes.bool, withHotkeys : PropTypes.bool, snow : PropTypes.func, onLogout : PropTypes.func.isRequired, intl : PropTypes.object.isRequired, }; static defaultProps = { enableChristmasSnow: true, }; handleLogoutClick = e => { e.preventDefault(); e.stopPropagation(); this.props.onLogout(); return false; }; constructor(props) { super(props); Date.prototype.getWeek = function () { var onejan = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); }; var weekNumber = (new Date()).getWeek(); // display snow during the last two weeks of the year console.log('week', weekNumber); const shouldWeDisplaySnow = (weekNumber > 48) && props.enableChristmasSnow; this.state = { enableChristmasSnow: shouldWeDisplaySnow }; // make snow effect if (shouldWeDisplaySnow) { import('../../../utils/snowstorm-min') .then((snowstorm) => { Window.snowstorm = snowstorm.default; this.state.snow = Window.snowstorm; console.log('this.state.snow ', this.state.snow); // snowstorm.start(); this.state.snowActive = true; }) .catch((err) => console.error(err)); } } toggleSnow = () => { console.log('toggle snow'); if (this.state.snow) { if (this.state.snowActive) { this.state.snow.stop(); this.state.snowActive = false; } else { this.state.snow.start(); this.state.snowActive = true; } } }; changeTheme(newTheme) { console.log('change theme en ', newTheme); } render() { const { withHotkeys } = this.props; var snowClasses = this.props.snowActive ? 'snow-button active' : 'snow-button '; return (
{/*// TODO*/} {/**/} {this.state.enableChristmasSnow && (