You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

684 lines
24 KiB

  1. import React from 'react';
  2. import NotificationsContainer from './containers/notifications_container';
  3. import PropTypes from 'prop-types';
  4. import LoadingBarContainer from './containers/loading_bar_container';
  5. import ModalContainer from './containers/modal_container';
  6. import { connect } from 'react-redux';
  7. import { Redirect, Route, withRouter } from 'react-router-dom';
  8. import { layoutFromWindow } from 'flavours/glitch/is_mobile';
  9. import { debounce } from 'lodash';
  10. import { uploadCompose, resetCompose, changeComposeSpoilerness } from 'flavours/glitch/actions/compose';
  11. import { expandHomeTimeline } from 'flavours/glitch/actions/timelines';
  12. import { expandNotifications, notificationsSetVisibility } from 'flavours/glitch/actions/notifications';
  13. import { fetchServer, fetchServerTranslationLanguages } from 'flavours/glitch/actions/server';
  14. import { clearHeight } from 'flavours/glitch/actions/height_cache';
  15. import { changeLayout } from 'flavours/glitch/actions/app';
  16. import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'flavours/glitch/actions/markers';
  17. import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers';
  18. import BundleColumnError from './components/bundle_column_error';
  19. import UploadArea from './components/upload_area';
  20. import PermaLink from 'flavours/glitch/components/permalink';
  21. import ColumnsAreaContainer from './containers/columns_area_container';
  22. import classNames from 'classnames';
  23. import Favico from 'favico.js';
  24. import PictureInPicture from 'flavours/glitch/features/picture_in_picture';
  25. import {
  26. Compose,
  27. Status,
  28. GettingStarted,
  29. KeyboardShortcuts,
  30. PublicTimeline,
  31. CommunityTimeline,
  32. AccountTimeline,
  33. AccountGallery,
  34. HomeTimeline,
  35. Followers,
  36. Following,
  37. Reblogs,
  38. Favourites,
  39. DirectTimeline,
  40. HashtagTimeline,
  41. Notifications,
  42. FollowRequests,
  43. FavouritedStatuses,
  44. BookmarkedStatuses,
  45. FollowedTags,
  46. ListTimeline,
  47. Blocks,
  48. DomainBlocks,
  49. Mutes,
  50. PinnedStatuses,
  51. Lists,
  52. GettingStartedMisc,
  53. Directory,
  54. Explore,
  55. FollowRecommendations,
  56. About,
  57. PrivacyPolicy,
  58. } from './util/async-components';
  59. import { HotKeys } from 'react-hotkeys';
  60. import initialState, { me, owner, singleUserMode, showTrends, trendsAsLanding } from '../../initial_state';
  61. import { closeOnboarding, INTRODUCTION_VERSION } from 'flavours/glitch/actions/onboarding';
  62. import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
  63. import { Helmet } from 'react-helmet';
  64. import Header from './components/header';
  65. // Dummy import, to make sure that <Status /> ends up in the application bundle.
  66. // Without this it ends up in ~8 very commonly used bundles.
  67. import '../../../glitch/components/status';
  68. const messages = defineMessages({
  69. beforeUnload: { id: 'ui.beforeunload', defaultMessage: 'Your draft will be lost if you leave Mastodon.' },
  70. });
  71. const mapStateToProps = state => ({
  72. layout: state.getIn(['meta', 'layout']),
  73. hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0,
  74. hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
  75. canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4,
  76. layout: state.getIn(['meta', 'layout']),
  77. layout_local_setting: state.getIn(['local_settings', 'layout']),
  78. isWide: state.getIn(['local_settings', 'stretch']),
  79. navbarUnder: state.getIn(['local_settings', 'navbar_under']),
  80. dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null,
  81. unreadNotifications: state.getIn(['notifications', 'unread']),
  82. showFaviconBadge: state.getIn(['local_settings', 'notifications', 'favicon_badge']),
  83. hicolorPrivacyIcons: state.getIn(['local_settings', 'hicolor_privacy_icons']),
  84. moved: state.getIn(['accounts', me, 'moved']) && state.getIn(['accounts', state.getIn(['accounts', me, 'moved'])]),
  85. firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION,
  86. username: state.getIn(['accounts', me, 'username']),
  87. });
  88. const keyMap = {
  89. help: '?',
  90. new: 'n',
  91. search: 's',
  92. forceNew: 'option+n',
  93. toggleComposeSpoilers: 'option+x',
  94. focusColumn: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
  95. reply: 'r',
  96. favourite: 'f',
  97. boost: 'b',
  98. mention: 'm',
  99. open: ['enter', 'o'],
  100. openProfile: 'p',
  101. moveDown: ['down', 'j'],
  102. moveUp: ['up', 'k'],
  103. back: 'backspace',
  104. goToHome: 'g h',
  105. goToNotifications: 'g n',
  106. goToLocal: 'g l',
  107. goToFederated: 'g t',
  108. goToDirect: 'g d',
  109. goToStart: 'g s',
  110. goToFavourites: 'g f',
  111. goToPinned: 'g p',
  112. goToProfile: 'g u',
  113. goToBlocked: 'g b',
  114. goToMuted: 'g m',
  115. goToRequests: 'g r',
  116. toggleSpoiler: 'x',
  117. bookmark: 'd',
  118. toggleCollapse: 'shift+x',
  119. toggleSensitive: 'h',
  120. openMedia: 'e',
  121. };
  122. class SwitchingColumnsArea extends React.PureComponent {
  123. static contextTypes = {
  124. identity: PropTypes.object,
  125. };
  126. static propTypes = {
  127. children: PropTypes.node,
  128. location: PropTypes.object,
  129. navbarUnder: PropTypes.bool,
  130. mobile: PropTypes.bool,
  131. };
  132. componentWillMount () {
  133. if (this.props.mobile) {
  134. document.body.classList.toggle('layout-single-column', true);
  135. document.body.classList.toggle('layout-multiple-columns', false);
  136. } else {
  137. document.body.classList.toggle('layout-single-column', false);
  138. document.body.classList.toggle('layout-multiple-columns', true);
  139. }
  140. }
  141. componentDidUpdate (prevProps) {
  142. if (![this.props.location.pathname, '/'].includes(prevProps.location.pathname)) {
  143. this.node.handleChildrenContentChange();
  144. }
  145. if (prevProps.mobile !== this.props.mobile) {
  146. document.body.classList.toggle('layout-single-column', this.props.mobile);
  147. document.body.classList.toggle('layout-multiple-columns', !this.props.mobile);
  148. }
  149. }
  150. setRef = c => {
  151. if (c) {
  152. this.node = c;
  153. }
  154. };
  155. render () {
  156. const { children, mobile, navbarUnder } = this.props;
  157. const { signedIn } = this.context.identity;
  158. let redirect;
  159. if (signedIn) {
  160. if (mobile) {
  161. redirect = <Redirect from='/' to='/public/local' exact />;
  162. } else {
  163. redirect = <Redirect from='/' to='/getting-started' exact />;
  164. }
  165. } else if (singleUserMode && owner && initialState?.accounts[owner]) {
  166. redirect = <Redirect from='/' to={`/@${initialState.accounts[owner].username}`} exact />;
  167. } else if (showTrends && trendsAsLanding) {
  168. redirect = <Redirect from='/' to='/explore' exact />;
  169. } else {
  170. redirect = <Redirect from='/' to='/about' exact />;
  171. }
  172. return (
  173. <ColumnsAreaContainer ref={this.setRef} singleColumn={mobile} navbarUnder={navbarUnder}>
  174. <WrappedSwitch>
  175. {redirect}
  176. <WrappedRoute path='/getting-started' component={GettingStarted} content={children} />
  177. <WrappedRoute path='/keyboard-shortcuts' component={KeyboardShortcuts} content={children} />
  178. <WrappedRoute path='/about' component={About} content={children} />
  179. <WrappedRoute path='/privacy-policy' component={PrivacyPolicy} content={children} />
  180. <WrappedRoute path={['/home', '/timelines/home']} component={HomeTimeline} content={children} />
  181. <WrappedRoute path={['/public', '/timelines/public']} exact component={PublicTimeline} content={children} />
  182. <WrappedRoute path={['/public/local', '/timelines/public/local']} exact component={CommunityTimeline} content={children} />
  183. <WrappedRoute path={['/conversations', '/timelines/direct']} component={DirectTimeline} content={children} />
  184. <WrappedRoute path='/tags/:id' component={HashtagTimeline} content={children} />
  185. <WrappedRoute path='/lists/:id' component={ListTimeline} content={children} />
  186. <WrappedRoute path='/notifications' component={Notifications} content={children} />
  187. <WrappedRoute path='/favourites' component={FavouritedStatuses} content={children} />
  188. <WrappedRoute path='/bookmarks' component={BookmarkedStatuses} content={children} />
  189. <WrappedRoute path='/pinned' component={PinnedStatuses} content={children} />
  190. <WrappedRoute path='/start' component={FollowRecommendations} content={children} />
  191. <WrappedRoute path='/directory' component={Directory} content={children} />
  192. <WrappedRoute path={['/explore', '/search']} component={Explore} content={children} />
  193. <WrappedRoute path={['/publish', '/statuses/new']} component={Compose} content={children} />
  194. <WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
  195. <WrappedRoute path='/@:acct/tagged/:tagged?' exact component={AccountTimeline} content={children} />
  196. <WrappedRoute path={['/@:acct/with_replies', '/accounts/:id/with_replies']} component={AccountTimeline} content={children} componentParams={{ withReplies: true }} />
  197. <WrappedRoute path={['/accounts/:id/followers', '/users/:acct/followers', '/@:acct/followers']} component={Followers} content={children} />
  198. <WrappedRoute path={['/accounts/:id/following', '/users/:acct/following', '/@:acct/following']} component={Following} content={children} />
  199. <WrappedRoute path={['/@:acct/media', '/accounts/:id/media']} component={AccountGallery} content={children} />
  200. <WrappedRoute path='/@:acct/:statusId' exact component={Status} content={children} />
  201. <WrappedRoute path='/@:acct/:statusId/reblogs' component={Reblogs} content={children} />
  202. <WrappedRoute path='/@:acct/:statusId/favourites' component={Favourites} content={children} />
  203. {/* Legacy routes, cannot be easily factored with other routes because they share a param name */}
  204. <WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} />
  205. <WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} />
  206. <WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} />
  207. <WrappedRoute path='/statuses/:statusId/reblogs' component={Reblogs} content={children} />
  208. <WrappedRoute path='/statuses/:statusId/favourites' component={Favourites} content={children} />
  209. <WrappedRoute path='/follow_requests' component={FollowRequests} content={children} />
  210. <WrappedRoute path='/blocks' component={Blocks} content={children} />
  211. <WrappedRoute path='/domain_blocks' component={DomainBlocks} content={children} />
  212. <WrappedRoute path='/followed_tags' component={FollowedTags} content={children} />
  213. <WrappedRoute path='/mutes' component={Mutes} content={children} />
  214. <WrappedRoute path='/lists' component={Lists} content={children} />
  215. <WrappedRoute path='/getting-started-misc' component={GettingStartedMisc} content={children} />
  216. <Route component={BundleColumnError} />
  217. </WrappedSwitch>
  218. </ColumnsAreaContainer>
  219. );
  220. }
  221. }
  222. class UI extends React.Component {
  223. static contextTypes = {
  224. identity: PropTypes.object.isRequired,
  225. };
  226. static propTypes = {
  227. dispatch: PropTypes.func.isRequired,
  228. children: PropTypes.node,
  229. layout_local_setting: PropTypes.string,
  230. isWide: PropTypes.bool,
  231. systemFontUi: PropTypes.bool,
  232. navbarUnder: PropTypes.bool,
  233. isComposing: PropTypes.bool,
  234. hasComposingText: PropTypes.bool,
  235. hasMediaAttachments: PropTypes.bool,
  236. canUploadMore: PropTypes.bool,
  237. match: PropTypes.object.isRequired,
  238. location: PropTypes.object.isRequired,
  239. history: PropTypes.object.isRequired,
  240. intl: PropTypes.object.isRequired,
  241. dropdownMenuIsOpen: PropTypes.bool,
  242. unreadNotifications: PropTypes.number,
  243. showFaviconBadge: PropTypes.bool,
  244. moved: PropTypes.map,
  245. layout: PropTypes.string.isRequired,
  246. firstLaunch: PropTypes.bool,
  247. username: PropTypes.string,
  248. };
  249. state = {
  250. draggingOver: false,
  251. };
  252. handleBeforeUnload = (e) => {
  253. const { intl, dispatch, hasComposingText, hasMediaAttachments } = this.props;
  254. dispatch(synchronouslySubmitMarkers());
  255. if (hasComposingText || hasMediaAttachments) {
  256. // Setting returnValue to any string causes confirmation dialog.
  257. // Many browsers no longer display this text to users,
  258. // but we set user-friendly message for other browsers, e.g. Edge.
  259. e.returnValue = intl.formatMessage(messages.beforeUnload);
  260. }
  261. };
  262. handleDragEnter = (e) => {
  263. e.preventDefault();
  264. if (!this.dragTargets) {
  265. this.dragTargets = [];
  266. }
  267. if (this.dragTargets.indexOf(e.target) === -1) {
  268. this.dragTargets.push(e.target);
  269. }
  270. if (e.dataTransfer && e.dataTransfer.types.includes('Files') && this.props.canUploadMore && this.context.identity.signedIn) {
  271. this.setState({ draggingOver: true });
  272. }
  273. };
  274. handleDragOver = (e) => {
  275. if (this.dataTransferIsText(e.dataTransfer)) return false;
  276. e.preventDefault();
  277. e.stopPropagation();
  278. try {
  279. e.dataTransfer.dropEffect = 'copy';
  280. } catch (err) {
  281. }
  282. return false;
  283. };
  284. handleDrop = (e) => {
  285. if (this.dataTransferIsText(e.dataTransfer)) return;
  286. e.preventDefault();
  287. this.setState({ draggingOver: false });
  288. this.dragTargets = [];
  289. if (e.dataTransfer && e.dataTransfer.files.length >= 1 && this.props.canUploadMore && this.context.identity.signedIn) {
  290. this.props.dispatch(uploadCompose(e.dataTransfer.files));
  291. }
  292. };
  293. handleDragLeave = (e) => {
  294. e.preventDefault();
  295. e.stopPropagation();
  296. this.dragTargets = this.dragTargets.filter(el => el !== e.target && this.node.contains(el));
  297. if (this.dragTargets.length > 0) {
  298. return;
  299. }
  300. this.setState({ draggingOver: false });
  301. };
  302. dataTransferIsText = (dataTransfer) => {
  303. return (dataTransfer && Array.from(dataTransfer.types).filter((type) => type === 'text/plain').length === 1);
  304. };
  305. closeUploadModal = () => {
  306. this.setState({ draggingOver: false });
  307. };
  308. handleServiceWorkerPostMessage = ({ data }) => {
  309. if (data.type === 'navigate') {
  310. this.props.history.push(data.path);
  311. } else {
  312. console.warn('Unknown message type:', data.type);
  313. }
  314. };
  315. handleVisibilityChange = () => {
  316. const visibility = !document[this.visibilityHiddenProp];
  317. this.props.dispatch(notificationsSetVisibility(visibility));
  318. if (visibility) {
  319. this.props.dispatch(submitMarkers({ immediate: true }));
  320. }
  321. };
  322. handleLayoutChange = debounce(() => {
  323. this.props.dispatch(clearHeight()); // The cached heights are no longer accurate, invalidate
  324. }, 500, {
  325. trailing: true,
  326. });
  327. handleResize = () => {
  328. const layout = layoutFromWindow(this.props.layout_local_setting);
  329. if (layout !== this.props.layout) {
  330. this.handleLayoutChange.cancel();
  331. this.props.dispatch(changeLayout(layout));
  332. } else {
  333. this.handleLayoutChange();
  334. }
  335. };
  336. componentDidMount () {
  337. const { signedIn } = this.context.identity;
  338. window.addEventListener('beforeunload', this.handleBeforeUnload, false);
  339. window.addEventListener('resize', this.handleResize, { passive: true });
  340. document.addEventListener('dragenter', this.handleDragEnter, false);
  341. document.addEventListener('dragover', this.handleDragOver, false);
  342. document.addEventListener('drop', this.handleDrop, false);
  343. document.addEventListener('dragleave', this.handleDragLeave, false);
  344. document.addEventListener('dragend', this.handleDragEnd, false);
  345. if ('serviceWorker' in navigator) {
  346. navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
  347. }
  348. this.favicon = new Favico({ animation:'none' });
  349. // On first launch, redirect to the follow recommendations page
  350. if (signedIn && this.props.firstLaunch) {
  351. this.context.router.history.replace('/start');
  352. this.props.dispatch(closeOnboarding());
  353. }
  354. if (signedIn) {
  355. this.props.dispatch(fetchMarkers());
  356. this.props.dispatch(expandHomeTimeline());
  357. this.props.dispatch(expandNotifications());
  358. this.props.dispatch(fetchServerTranslationLanguages());
  359. setTimeout(() => this.props.dispatch(fetchServer()), 3000);
  360. }
  361. this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
  362. return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
  363. };
  364. if (typeof document.hidden !== 'undefined') { // Opera 12.10 and Firefox 18 and later support
  365. this.visibilityHiddenProp = 'hidden';
  366. this.visibilityChange = 'visibilitychange';
  367. } else if (typeof document.msHidden !== 'undefined') {
  368. this.visibilityHiddenProp = 'msHidden';
  369. this.visibilityChange = 'msvisibilitychange';
  370. } else if (typeof document.webkitHidden !== 'undefined') {
  371. this.visibilityHiddenProp = 'webkitHidden';
  372. this.visibilityChange = 'webkitvisibilitychange';
  373. }
  374. if (this.visibilityChange !== undefined) {
  375. document.addEventListener(this.visibilityChange, this.handleVisibilityChange, false);
  376. this.handleVisibilityChange();
  377. }
  378. }
  379. componentWillReceiveProps (nextProps) {
  380. if (nextProps.layout_local_setting !== this.props.layout_local_setting) {
  381. const layout = layoutFromWindow(nextProps.layout_local_setting);
  382. if (layout !== this.props.layout) {
  383. this.handleLayoutChange.cancel();
  384. this.props.dispatch(changeLayout(layout));
  385. } else {
  386. this.handleLayoutChange();
  387. }
  388. }
  389. }
  390. componentDidUpdate (prevProps) {
  391. if (this.props.unreadNotifications != prevProps.unreadNotifications ||
  392. this.props.showFaviconBadge != prevProps.showFaviconBadge) {
  393. if (this.favicon) {
  394. try {
  395. this.favicon.badge(this.props.showFaviconBadge ? this.props.unreadNotifications : 0);
  396. } catch (err) {
  397. console.error(err);
  398. }
  399. }
  400. }
  401. }
  402. componentWillUnmount () {
  403. if (this.visibilityChange !== undefined) {
  404. document.removeEventListener(this.visibilityChange, this.handleVisibilityChange);
  405. }
  406. window.removeEventListener('beforeunload', this.handleBeforeUnload);
  407. window.removeEventListener('resize', this.handleResize);
  408. document.removeEventListener('dragenter', this.handleDragEnter);
  409. document.removeEventListener('dragover', this.handleDragOver);
  410. document.removeEventListener('drop', this.handleDrop);
  411. document.removeEventListener('dragleave', this.handleDragLeave);
  412. document.removeEventListener('dragend', this.handleDragEnd);
  413. }
  414. setRef = c => {
  415. this.node = c;
  416. };
  417. handleHotkeyNew = e => {
  418. e.preventDefault();
  419. const element = this.node.querySelector('.compose-form__autosuggest-wrapper textarea');
  420. if (element) {
  421. element.focus();
  422. }
  423. };
  424. handleHotkeySearch = e => {
  425. e.preventDefault();
  426. const element = this.node.querySelector('.search__input');
  427. if (element) {
  428. element.focus();
  429. }
  430. };
  431. handleHotkeyForceNew = e => {
  432. this.handleHotkeyNew(e);
  433. this.props.dispatch(resetCompose());
  434. };
  435. handleHotkeyToggleComposeSpoilers = e => {
  436. e.preventDefault();
  437. this.props.dispatch(changeComposeSpoilerness());
  438. };
  439. handleHotkeyFocusColumn = e => {
  440. const index = (e.key * 1) + 1; // First child is drawer, skip that
  441. const column = this.node.querySelector(`.column:nth-child(${index})`);
  442. if (!column) return;
  443. const container = column.querySelector('.scrollable');
  444. if (container) {
  445. const status = container.querySelector('.focusable');
  446. if (status) {
  447. if (container.scrollTop > status.offsetTop) {
  448. status.scrollIntoView(true);
  449. }
  450. status.focus();
  451. }
  452. }
  453. };
  454. handleHotkeyBack = () => {
  455. // if history is exhausted, or we would leave mastodon, just go to root.
  456. if (window.history.state) {
  457. this.props.history.goBack();
  458. } else {
  459. this.props.history.push('/');
  460. }
  461. };
  462. setHotkeysRef = c => {
  463. this.hotkeys = c;
  464. };
  465. handleHotkeyToggleHelp = () => {
  466. if (this.props.location.pathname === '/keyboard-shortcuts') {
  467. this.props.history.goBack();
  468. } else {
  469. this.props.history.push('/keyboard-shortcuts');
  470. }
  471. };
  472. handleHotkeyGoToHome = () => {
  473. this.props.history.push('/home');
  474. };
  475. handleHotkeyGoToNotifications = () => {
  476. this.props.history.push('/notifications');
  477. };
  478. handleHotkeyGoToLocal = () => {
  479. this.props.history.push('/public/local');
  480. };
  481. handleHotkeyGoToFederated = () => {
  482. this.props.history.push('/public');
  483. };
  484. handleHotkeyGoToDirect = () => {
  485. this.props.history.push('/conversations');
  486. };
  487. handleHotkeyGoToStart = () => {
  488. this.props.history.push('/getting-started');
  489. };
  490. handleHotkeyGoToFavourites = () => {
  491. this.props.history.push('/favourites');
  492. };
  493. handleHotkeyGoToPinned = () => {
  494. this.props.history.push('/pinned');
  495. };
  496. handleHotkeyGoToProfile = () => {
  497. this.props.history.push(`/@${this.props.username}`);
  498. };
  499. handleHotkeyGoToBlocked = () => {
  500. this.props.history.push('/blocks');
  501. };
  502. handleHotkeyGoToMuted = () => {
  503. this.props.history.push('/mutes');
  504. };
  505. handleHotkeyGoToRequests = () => {
  506. this.props.history.push('/follow_requests');
  507. };
  508. render () {
  509. const { draggingOver } = this.state;
  510. const { children, isWide, navbarUnder, location, dropdownMenuIsOpen, layout, moved } = this.props;
  511. const columnsClass = layout => {
  512. switch (layout) {
  513. case 'single':
  514. return 'single-column';
  515. case 'multiple':
  516. return 'multi-columns';
  517. default:
  518. return 'auto-columns';
  519. }
  520. };
  521. const className = classNames('ui', columnsClass(layout), {
  522. 'wide': isWide,
  523. 'system-font': this.props.systemFontUi,
  524. 'navbar-under': navbarUnder,
  525. 'hicolor-privacy-icons': this.props.hicolorPrivacyIcons,
  526. });
  527. const handlers = {
  528. help: this.handleHotkeyToggleHelp,
  529. new: this.handleHotkeyNew,
  530. search: this.handleHotkeySearch,
  531. forceNew: this.handleHotkeyForceNew,
  532. toggleComposeSpoilers: this.handleHotkeyToggleComposeSpoilers,
  533. focusColumn: this.handleHotkeyFocusColumn,
  534. back: this.handleHotkeyBack,
  535. goToHome: this.handleHotkeyGoToHome,
  536. goToNotifications: this.handleHotkeyGoToNotifications,
  537. goToLocal: this.handleHotkeyGoToLocal,
  538. goToFederated: this.handleHotkeyGoToFederated,
  539. goToDirect: this.handleHotkeyGoToDirect,
  540. goToStart: this.handleHotkeyGoToStart,
  541. goToFavourites: this.handleHotkeyGoToFavourites,
  542. goToPinned: this.handleHotkeyGoToPinned,
  543. goToProfile: this.handleHotkeyGoToProfile,
  544. goToBlocked: this.handleHotkeyGoToBlocked,
  545. goToMuted: this.handleHotkeyGoToMuted,
  546. goToRequests: this.handleHotkeyGoToRequests,
  547. };
  548. return (
  549. <HotKeys keyMap={keyMap} handlers={handlers} ref={this.setHotkeysRef} attach={window} focused>
  550. <div className={className} ref={this.setRef} style={{ pointerEvents: dropdownMenuIsOpen ? 'none' : null }}>
  551. {moved && (<div className='flash-message alert'>
  552. <FormattedMessage
  553. id='moved_to_warning'
  554. defaultMessage='This account is marked as moved to {moved_to_link}, and may thus not accept new follows.'
  555. values={{ moved_to_link: (
  556. <PermaLink href={moved.get('url')} to={`/@${moved.get('acct')}`}>
  557. @{moved.get('acct')}
  558. </PermaLink>
  559. ) }}
  560. />
  561. </div>)}
  562. <Header />
  563. <SwitchingColumnsArea location={location} mobile={layout === 'mobile' || layout === 'single-column'} navbarUnder={navbarUnder}>
  564. {children}
  565. </SwitchingColumnsArea>
  566. {layout !== 'mobile' && <PictureInPicture />}
  567. <NotificationsContainer />
  568. <LoadingBarContainer className='loading-bar' />
  569. <ModalContainer />
  570. <UploadArea active={draggingOver} onClose={this.closeUploadModal} />
  571. </div>
  572. </HotKeys>
  573. );
  574. }
  575. }
  576. export default connect(mapStateToProps)(injectIntl(withRouter(UI)));