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.

590 lines
20 KiB

Revamp post filtering system (#18058) * Add model for custom filter keywords * Use CustomFilterKeyword internally Does not change the API * Fix /filters/edit and /filters/new * Add migration tests * Remove whole_word column from custom_filters (covered by custom_filter_keywords) * Redesign /filters Instead of a list, present a card that displays more information and handles multiple keywords per filter. * Redesign /filters/new and /filters/edit to add and remove keywords This adds a new gem dependency: cocoon, as well as a npm dependency: cocoon-js-vanilla. Those are used to easily populate and remove form fields from the user interface when manipulating multiple keyword filters at once. * Add /api/v2/filters to edit filter with multiple keywords Entities: - `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context` `keywords` - `FilterKeyword`: `id`, `keyword`, `whole_word` API endpoits: - `GET /api/v2/filters` to list filters (including keywords) - `POST /api/v2/filters` to create a new filter `keywords_attributes` can also be passed to create keywords in one request - `GET /api/v2/filters/:id` to read a particular filter - `PUT /api/v2/filters/:id` to update a new filter `keywords_attributes` can also be passed to edit, delete or add keywords in one request - `DELETE /api/v2/filters/:id` to delete a particular filter - `GET /api/v2/filters/:id/keywords` to list keywords for a filter - `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a filter - `GET /api/v2/filter_keywords/:id` to read a particular keyword - `PUT /api/v2/filter_keywords/:id` to edit a particular keyword - `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword * Change from `irreversible` boolean to `action` enum * Remove irrelevent `irreversible_must_be_within_context` check * Fix /filters/new and /filters/edit with update for filter_action * Fix Rubocop/Codeclimate complaining about task names * Refactor FeedManager#phrase_filtered? This moves regexp building and filter caching to the `CustomFilter` class. This does not change the functional behavior yet, but this changes how the cache is built, doing per-custom_filter regexps so that filters can be matched independently, while still offering caching. * Perform server-side filtering and output result in REST API * Fix numerous filters_changed events being sent when editing multiple keywords at once * Add some tests * Use the new API in the WebUI - use client-side logic for filters we have fetched rules for. This is so that filter changes can be retroactively applied without reloading the UI. - use server-side logic for filters we haven't fetched rules for yet (e.g. network error, or initial timeline loading) * Minor optimizations and refactoring * Perform server-side filtering on the streaming server * Change the wording of filter action labels * Fix issues pointed out by linter * Change design of “Show anyway” link in accordence to review comments * Drop “irreversible” filtering behavior * Move /api/v2/filter_keywords to /api/v1/filters/keywords * Rename `filter_results` attribute to `filtered` * Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer * Fix systemChannelId value in streaming server * Simplify code by removing client-side filtering code The simplifcation comes at a cost though: filters aren't retroactively applied anymore.
2 years ago
  1. import classNames from 'classnames';
  2. import React from 'react';
  3. import { HotKeys } from 'react-hotkeys';
  4. import { defineMessages, injectIntl } from 'react-intl';
  5. import { connect } from 'react-redux';
  6. import { Redirect, Route, withRouter } from 'react-router-dom';
  7. import PropTypes from 'prop-types';
  8. import NotificationsContainer from './containers/notifications_container';
  9. import LoadingBarContainer from './containers/loading_bar_container';
  10. import ModalContainer from './containers/modal_container';
  11. import { layoutFromWindow } from 'mastodon/is_mobile';
  12. import { debounce } from 'lodash';
  13. import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose';
  14. import { expandHomeTimeline } from '../../actions/timelines';
  15. import { expandNotifications } from '../../actions/notifications';
  16. import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server';
  17. import { clearHeight } from '../../actions/height_cache';
  18. import { focusApp, unfocusApp, changeLayout } from 'mastodon/actions/app';
  19. import { synchronouslySubmitMarkers, submitMarkers, fetchMarkers } from 'mastodon/actions/markers';
  20. import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers';
  21. import BundleColumnError from './components/bundle_column_error';
  22. import UploadArea from './components/upload_area';
  23. import ColumnsAreaContainer from './containers/columns_area_container';
  24. import PictureInPicture from 'mastodon/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. Directory,
  53. Explore,
  54. FollowRecommendations,
  55. About,
  56. PrivacyPolicy,
  57. } from './util/async-components';
  58. import initialState, { me, owner, singleUserMode, showTrends, trendsAsLanding } from '../../initial_state';
  59. import { closeOnboarding, INTRODUCTION_VERSION } from 'mastodon/actions/onboarding';
  60. import Header from './components/header';
  61. // Dummy import, to make sure that <Status /> ends up in the application bundle.
  62. // Without this it ends up in ~8 very commonly used bundles.
  63. import '../../components/status';
  64. const messages = defineMessages({
  65. beforeUnload: { id: 'ui.beforeunload', defaultMessage: 'Your draft will be lost if you leave Mastodon.' },
  66. });
  67. const mapStateToProps = state => ({
  68. layout: state.getIn(['meta', 'layout']),
  69. isComposing: state.getIn(['compose', 'is_composing']),
  70. hasComposingText: state.getIn(['compose', 'text']).trim().length !== 0,
  71. hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
  72. canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < 4,
  73. dropdownMenuIsOpen: state.getIn(['dropdown_menu', 'openId']) !== null,
  74. firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION,
  75. username: state.getIn(['accounts', me, 'username']),
  76. });
  77. const keyMap = {
  78. help: '?',
  79. new: 'n',
  80. search: 's',
  81. forceNew: 'option+n',
  82. toggleComposeSpoilers: 'option+x',
  83. focusColumn: ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
  84. reply: 'r',
  85. favourite: 'f',
  86. boost: 'b',
  87. mention: 'm',
  88. open: ['enter', 'o'],
  89. openProfile: 'p',
  90. moveDown: ['down', 'j'],
  91. moveUp: ['up', 'k'],
  92. back: 'backspace',
  93. goToHome: 'g h',
  94. goToNotifications: 'g n',
  95. goToLocal: 'g l',
  96. goToFederated: 'g t',
  97. goToDirect: 'g d',
  98. goToStart: 'g s',
  99. goToFavourites: 'g f',
  100. goToPinned: 'g p',
  101. goToProfile: 'g u',
  102. goToBlocked: 'g b',
  103. goToMuted: 'g m',
  104. goToRequests: 'g r',
  105. toggleHidden: 'x',
  106. toggleSensitive: 'h',
  107. openMedia: 'e',
  108. };
  109. class SwitchingColumnsArea extends React.PureComponent {
  110. static contextTypes = {
  111. identity: PropTypes.object,
  112. };
  113. static propTypes = {
  114. children: PropTypes.node,
  115. location: PropTypes.object,
  116. mobile: PropTypes.bool,
  117. };
  118. componentWillMount () {
  119. if (this.props.mobile) {
  120. document.body.classList.toggle('layout-single-column', true);
  121. document.body.classList.toggle('layout-multiple-columns', false);
  122. } else {
  123. document.body.classList.toggle('layout-single-column', false);
  124. document.body.classList.toggle('layout-multiple-columns', true);
  125. }
  126. }
  127. componentDidUpdate (prevProps) {
  128. if (![this.props.location.pathname, '/'].includes(prevProps.location.pathname)) {
  129. this.node.handleChildrenContentChange();
  130. }
  131. if (prevProps.mobile !== this.props.mobile) {
  132. document.body.classList.toggle('layout-single-column', this.props.mobile);
  133. document.body.classList.toggle('layout-multiple-columns', !this.props.mobile);
  134. }
  135. }
  136. setRef = c => {
  137. if (c) {
  138. this.node = c;
  139. }
  140. };
  141. render () {
  142. const { children, mobile } = this.props;
  143. const { signedIn } = this.context.identity;
  144. let redirect;
  145. if (signedIn) {
  146. if (mobile) {
  147. redirect = <Redirect from='/' to='/home' exact />;
  148. } else {
  149. redirect = <Redirect from='/' to='/getting-started' exact />;
  150. }
  151. } else if (singleUserMode && owner && initialState?.accounts[owner]) {
  152. redirect = <Redirect from='/' to={`/@${initialState.accounts[owner].username}`} exact />;
  153. } else if (showTrends && trendsAsLanding) {
  154. redirect = <Redirect from='/' to='/explore' exact />;
  155. } else {
  156. redirect = <Redirect from='/' to='/about' exact />;
  157. }
  158. return (
  159. <ColumnsAreaContainer ref={this.setRef} singleColumn={mobile}>
  160. <WrappedSwitch>
  161. {redirect}
  162. <WrappedRoute path='/getting-started' component={GettingStarted} content={children} />
  163. <WrappedRoute path='/keyboard-shortcuts' component={KeyboardShortcuts} content={children} />
  164. <WrappedRoute path='/about' component={About} content={children} />
  165. <WrappedRoute path='/privacy-policy' component={PrivacyPolicy} content={children} />
  166. <WrappedRoute path={['/home', '/timelines/home']} component={HomeTimeline} content={children} />
  167. <WrappedRoute path={['/public', '/timelines/public']} exact component={PublicTimeline} content={children} />
  168. <WrappedRoute path={['/public/local', '/timelines/public/local']} exact component={CommunityTimeline} content={children} />
  169. <WrappedRoute path={['/conversations', '/timelines/direct']} component={DirectTimeline} content={children} />
  170. <WrappedRoute path='/tags/:id' component={HashtagTimeline} content={children} />
  171. <WrappedRoute path='/lists/:id' component={ListTimeline} content={children} />
  172. <WrappedRoute path='/notifications' component={Notifications} content={children} />
  173. <WrappedRoute path='/favourites' component={FavouritedStatuses} content={children} />
  174. <WrappedRoute path='/bookmarks' component={BookmarkedStatuses} content={children} />
  175. <WrappedRoute path='/pinned' component={PinnedStatuses} content={children} />
  176. <WrappedRoute path='/start' component={FollowRecommendations} content={children} />
  177. <WrappedRoute path='/directory' component={Directory} content={children} />
  178. <WrappedRoute path={['/explore', '/search']} component={Explore} content={children} />
  179. <WrappedRoute path={['/publish', '/statuses/new']} component={Compose} content={children} />
  180. <WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
  181. <WrappedRoute path='/@:acct/tagged/:tagged?' exact component={AccountTimeline} content={children} />
  182. <WrappedRoute path={['/@:acct/with_replies', '/accounts/:id/with_replies']} component={AccountTimeline} content={children} componentParams={{ withReplies: true }} />
  183. <WrappedRoute path={['/accounts/:id/followers', '/users/:acct/followers', '/@:acct/followers']} component={Followers} content={children} />
  184. <WrappedRoute path={['/accounts/:id/following', '/users/:acct/following', '/@:acct/following']} component={Following} content={children} />
  185. <WrappedRoute path={['/@:acct/media', '/accounts/:id/media']} component={AccountGallery} content={children} />
  186. <WrappedRoute path='/@:acct/:statusId' exact component={Status} content={children} />
  187. <WrappedRoute path='/@:acct/:statusId/reblogs' component={Reblogs} content={children} />
  188. <WrappedRoute path='/@:acct/:statusId/favourites' component={Favourites} content={children} />
  189. {/* Legacy routes, cannot be easily factored with other routes because they share a param name */}
  190. <WrappedRoute path='/timelines/tag/:id' component={HashtagTimeline} content={children} />
  191. <WrappedRoute path='/timelines/list/:id' component={ListTimeline} content={children} />
  192. <WrappedRoute path='/statuses/:statusId' exact component={Status} content={children} />
  193. <WrappedRoute path='/statuses/:statusId/reblogs' component={Reblogs} content={children} />
  194. <WrappedRoute path='/statuses/:statusId/favourites' component={Favourites} content={children} />
  195. <WrappedRoute path='/follow_requests' component={FollowRequests} content={children} />
  196. <WrappedRoute path='/blocks' component={Blocks} content={children} />
  197. <WrappedRoute path='/domain_blocks' component={DomainBlocks} content={children} />
  198. <WrappedRoute path='/followed_tags' component={FollowedTags} content={children} />
  199. <WrappedRoute path='/mutes' component={Mutes} content={children} />
  200. <WrappedRoute path='/lists' component={Lists} content={children} />
  201. <Route component={BundleColumnError} />
  202. </WrappedSwitch>
  203. </ColumnsAreaContainer>
  204. );
  205. }
  206. }
  207. export default @connect(mapStateToProps)
  208. @injectIntl
  209. @withRouter
  210. class UI extends React.PureComponent {
  211. static contextTypes = {
  212. router: PropTypes.object.isRequired,
  213. identity: PropTypes.object.isRequired,
  214. };
  215. static propTypes = {
  216. dispatch: PropTypes.func.isRequired,
  217. children: PropTypes.node,
  218. isComposing: PropTypes.bool,
  219. hasComposingText: PropTypes.bool,
  220. hasMediaAttachments: PropTypes.bool,
  221. canUploadMore: PropTypes.bool,
  222. location: PropTypes.object,
  223. intl: PropTypes.object.isRequired,
  224. dropdownMenuIsOpen: PropTypes.bool,
  225. layout: PropTypes.string.isRequired,
  226. firstLaunch: PropTypes.bool,
  227. username: PropTypes.string,
  228. };
  229. state = {
  230. draggingOver: false,
  231. };
  232. handleBeforeUnload = e => {
  233. const { intl, dispatch, isComposing, hasComposingText, hasMediaAttachments } = this.props;
  234. dispatch(synchronouslySubmitMarkers());
  235. if (isComposing && (hasComposingText || hasMediaAttachments)) {
  236. e.preventDefault();
  237. // Setting returnValue to any string causes confirmation dialog.
  238. // Many browsers no longer display this text to users,
  239. // but we set user-friendly message for other browsers, e.g. Edge.
  240. e.returnValue = intl.formatMessage(messages.beforeUnload);
  241. }
  242. };
  243. handleWindowFocus = () => {
  244. this.props.dispatch(focusApp());
  245. this.props.dispatch(submitMarkers({ immediate: true }));
  246. };
  247. handleWindowBlur = () => {
  248. this.props.dispatch(unfocusApp());
  249. };
  250. handleDragEnter = (e) => {
  251. e.preventDefault();
  252. if (!this.dragTargets) {
  253. this.dragTargets = [];
  254. }
  255. if (this.dragTargets.indexOf(e.target) === -1) {
  256. this.dragTargets.push(e.target);
  257. }
  258. if (e.dataTransfer && Array.from(e.dataTransfer.types).includes('Files') && this.props.canUploadMore && this.context.identity.signedIn) {
  259. this.setState({ draggingOver: true });
  260. }
  261. };
  262. handleDragOver = (e) => {
  263. if (this.dataTransferIsText(e.dataTransfer)) return false;
  264. e.preventDefault();
  265. e.stopPropagation();
  266. try {
  267. e.dataTransfer.dropEffect = 'copy';
  268. } catch (err) {
  269. }
  270. return false;
  271. };
  272. handleDrop = (e) => {
  273. if (this.dataTransferIsText(e.dataTransfer)) return;
  274. e.preventDefault();
  275. this.setState({ draggingOver: false });
  276. this.dragTargets = [];
  277. if (e.dataTransfer && e.dataTransfer.files.length >= 1 && this.props.canUploadMore && this.context.identity.signedIn) {
  278. this.props.dispatch(uploadCompose(e.dataTransfer.files));
  279. }
  280. };
  281. handleDragLeave = (e) => {
  282. e.preventDefault();
  283. e.stopPropagation();
  284. this.dragTargets = this.dragTargets.filter(el => el !== e.target && this.node.contains(el));
  285. if (this.dragTargets.length > 0) {
  286. return;
  287. }
  288. this.setState({ draggingOver: false });
  289. };
  290. dataTransferIsText = (dataTransfer) => {
  291. return (dataTransfer && Array.from(dataTransfer.types).filter((type) => type === 'text/plain').length === 1);
  292. };
  293. closeUploadModal = () => {
  294. this.setState({ draggingOver: false });
  295. };
  296. handleServiceWorkerPostMessage = ({ data }) => {
  297. if (data.type === 'navigate') {
  298. this.context.router.history.push(data.path);
  299. } else {
  300. console.warn('Unknown message type:', data.type);
  301. }
  302. };
  303. handleLayoutChange = debounce(() => {
  304. this.props.dispatch(clearHeight()); // The cached heights are no longer accurate, invalidate
  305. }, 500, {
  306. trailing: true,
  307. });
  308. handleResize = () => {
  309. const layout = layoutFromWindow();
  310. if (layout !== this.props.layout) {
  311. this.handleLayoutChange.cancel();
  312. this.props.dispatch(changeLayout(layout));
  313. } else {
  314. this.handleLayoutChange();
  315. }
  316. };
  317. componentDidMount () {
  318. const { signedIn } = this.context.identity;
  319. window.addEventListener('focus', this.handleWindowFocus, false);
  320. window.addEventListener('blur', this.handleWindowBlur, false);
  321. window.addEventListener('beforeunload', this.handleBeforeUnload, false);
  322. window.addEventListener('resize', this.handleResize, { passive: true });
  323. document.addEventListener('dragenter', this.handleDragEnter, false);
  324. document.addEventListener('dragover', this.handleDragOver, false);
  325. document.addEventListener('drop', this.handleDrop, false);
  326. document.addEventListener('dragleave', this.handleDragLeave, false);
  327. document.addEventListener('dragend', this.handleDragEnd, false);
  328. if ('serviceWorker' in navigator) {
  329. navigator.serviceWorker.addEventListener('message', this.handleServiceWorkerPostMessage);
  330. }
  331. // On first launch, redirect to the follow recommendations page
  332. if (signedIn && this.props.firstLaunch) {
  333. this.context.router.history.replace('/start');
  334. this.props.dispatch(closeOnboarding());
  335. }
  336. if (signedIn) {
  337. this.props.dispatch(fetchMarkers());
  338. this.props.dispatch(expandHomeTimeline());
  339. this.props.dispatch(expandNotifications());
  340. this.props.dispatch(fetchServerTranslationLanguages());
  341. setTimeout(() => this.props.dispatch(fetchServer()), 3000);
  342. }
  343. this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
  344. return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
  345. };
  346. }
  347. componentWillUnmount () {
  348. window.removeEventListener('focus', this.handleWindowFocus);
  349. window.removeEventListener('blur', this.handleWindowBlur);
  350. window.removeEventListener('beforeunload', this.handleBeforeUnload);
  351. window.removeEventListener('resize', this.handleResize);
  352. document.removeEventListener('dragenter', this.handleDragEnter);
  353. document.removeEventListener('dragover', this.handleDragOver);
  354. document.removeEventListener('drop', this.handleDrop);
  355. document.removeEventListener('dragleave', this.handleDragLeave);
  356. document.removeEventListener('dragend', this.handleDragEnd);
  357. }
  358. setRef = c => {
  359. this.node = c;
  360. };
  361. handleHotkeyNew = e => {
  362. e.preventDefault();
  363. const element = this.node.querySelector('.compose-form__autosuggest-wrapper textarea');
  364. if (element) {
  365. element.focus();
  366. }
  367. };
  368. handleHotkeySearch = e => {
  369. e.preventDefault();
  370. const element = this.node.querySelector('.search__input');
  371. if (element) {
  372. element.focus();
  373. }
  374. };
  375. handleHotkeyForceNew = e => {
  376. this.handleHotkeyNew(e);
  377. this.props.dispatch(resetCompose());
  378. };
  379. handleHotkeyToggleComposeSpoilers = e => {
  380. e.preventDefault();
  381. this.props.dispatch(changeComposeSpoilerness());
  382. };
  383. handleHotkeyFocusColumn = e => {
  384. const index = (e.key * 1) + 1; // First child is drawer, skip that
  385. const column = this.node.querySelector(`.column:nth-child(${index})`);
  386. if (!column) return;
  387. const container = column.querySelector('.scrollable');
  388. if (container) {
  389. const status = container.querySelector('.focusable');
  390. if (status) {
  391. if (container.scrollTop > status.offsetTop) {
  392. status.scrollIntoView(true);
  393. }
  394. status.focus();
  395. }
  396. }
  397. };
  398. handleHotkeyBack = () => {
  399. if (window.history && window.history.state) {
  400. this.context.router.history.goBack();
  401. } else {
  402. this.context.router.history.push('/');
  403. }
  404. };
  405. setHotkeysRef = c => {
  406. this.hotkeys = c;
  407. };
  408. handleHotkeyToggleHelp = () => {
  409. if (this.props.location.pathname === '/keyboard-shortcuts') {
  410. this.context.router.history.goBack();
  411. } else {
  412. this.context.router.history.push('/keyboard-shortcuts');
  413. }
  414. };
  415. handleHotkeyGoToHome = () => {
  416. this.context.router.history.push('/home');
  417. };
  418. handleHotkeyGoToNotifications = () => {
  419. this.context.router.history.push('/notifications');
  420. };
  421. handleHotkeyGoToLocal = () => {
  422. this.context.router.history.push('/public/local');
  423. };
  424. handleHotkeyGoToFederated = () => {
  425. this.context.router.history.push('/public');
  426. };
  427. handleHotkeyGoToDirect = () => {
  428. this.context.router.history.push('/conversations');
  429. };
  430. handleHotkeyGoToStart = () => {
  431. this.context.router.history.push('/getting-started');
  432. };
  433. handleHotkeyGoToFavourites = () => {
  434. this.context.router.history.push('/favourites');
  435. };
  436. handleHotkeyGoToPinned = () => {
  437. this.context.router.history.push('/pinned');
  438. };
  439. handleHotkeyGoToProfile = () => {
  440. this.context.router.history.push(`/@${this.props.username}`);
  441. };
  442. handleHotkeyGoToBlocked = () => {
  443. this.context.router.history.push('/blocks');
  444. };
  445. handleHotkeyGoToMuted = () => {
  446. this.context.router.history.push('/mutes');
  447. };
  448. handleHotkeyGoToRequests = () => {
  449. this.context.router.history.push('/follow_requests');
  450. };
  451. render () {
  452. const { draggingOver } = this.state;
  453. const { children, isComposing, location, dropdownMenuIsOpen, layout } = this.props;
  454. const handlers = {
  455. help: this.handleHotkeyToggleHelp,
  456. new: this.handleHotkeyNew,
  457. search: this.handleHotkeySearch,
  458. forceNew: this.handleHotkeyForceNew,
  459. toggleComposeSpoilers: this.handleHotkeyToggleComposeSpoilers,
  460. focusColumn: this.handleHotkeyFocusColumn,
  461. back: this.handleHotkeyBack,
  462. goToHome: this.handleHotkeyGoToHome,
  463. goToNotifications: this.handleHotkeyGoToNotifications,
  464. goToLocal: this.handleHotkeyGoToLocal,
  465. goToFederated: this.handleHotkeyGoToFederated,
  466. goToDirect: this.handleHotkeyGoToDirect,
  467. goToStart: this.handleHotkeyGoToStart,
  468. goToFavourites: this.handleHotkeyGoToFavourites,
  469. goToPinned: this.handleHotkeyGoToPinned,
  470. goToProfile: this.handleHotkeyGoToProfile,
  471. goToBlocked: this.handleHotkeyGoToBlocked,
  472. goToMuted: this.handleHotkeyGoToMuted,
  473. goToRequests: this.handleHotkeyGoToRequests,
  474. };
  475. return (
  476. <HotKeys keyMap={keyMap} handlers={handlers} ref={this.setHotkeysRef} attach={window} focused>
  477. <div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef} style={{ pointerEvents: dropdownMenuIsOpen ? 'none' : null }}>
  478. <Header />
  479. <SwitchingColumnsArea location={location} mobile={layout === 'mobile' || layout === 'single-column'}>
  480. {children}
  481. </SwitchingColumnsArea>
  482. {layout !== 'mobile' && <PictureInPicture />}
  483. <NotificationsContainer />
  484. <LoadingBarContainer className='loading-bar' />
  485. <ModalContainer />
  486. <UploadArea active={draggingOver} onClose={this.closeUploadModal} />
  487. </div>
  488. </HotKeys>
  489. );
  490. }
  491. }