From 155424e52f2d382ccaf4560b2d62aba347a8992b Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 3 Feb 2023 20:52:07 +0100 Subject: [Glitch] Run eslint --fix I don't like it changing files this way, but it's basically what c49213f0ea311daba590db1d7a14a641cbd9fe93 and a few others did. --- .../flavours/glitch/components/account.js | 12 ++-- .../flavours/glitch/components/admin/Retention.js | 2 +- .../flavours/glitch/components/animated_number.js | 4 +- .../glitch/components/autosuggest_input.js | 14 ++--- .../glitch/components/autosuggest_textarea.js | 16 +++--- .../flavours/glitch/components/avatar.js | 4 +- .../flavours/glitch/components/button.js | 4 +- .../flavours/glitch/components/column.js | 4 +- .../glitch/components/column_back_button.js | 2 +- .../glitch/components/column_back_button_slim.js | 2 +- .../flavours/glitch/components/column_header.js | 16 +++--- .../glitch/components/dismissable_banner.js | 2 +- .../flavours/glitch/components/display_name.js | 6 +- .../flavours/glitch/components/domain.js | 2 +- .../flavours/glitch/components/dropdown_menu.js | 34 ++++++------ .../glitch/components/edited_timestamp/index.js | 4 +- .../flavours/glitch/components/error_boundary.js | 2 +- app/javascript/flavours/glitch/components/gifv.js | 4 +- .../flavours/glitch/components/icon_button.js | 10 ++-- .../components/intersection_observer_article.js | 17 +++--- .../flavours/glitch/components/load_gap.js | 2 +- .../flavours/glitch/components/load_more.js | 4 +- .../flavours/glitch/components/load_pending.js | 2 +- .../glitch/components/media_attachments.js | 6 +- .../flavours/glitch/components/media_gallery.js | 18 +++--- .../flavours/glitch/components/modal_root.js | 9 +-- .../flavours/glitch/components/permalink.js | 4 +- .../components/picture_in_picture_placeholder.js | 4 +- app/javascript/flavours/glitch/components/poll.js | 4 +- .../flavours/glitch/components/scrollable_list.js | 22 ++++---- .../flavours/glitch/components/setting_text.js | 2 +- .../flavours/glitch/components/spoilers.js | 30 +++++----- .../flavours/glitch/components/status.js | 64 +++++++++++----------- .../glitch/components/status_action_bar.js | 44 +++++++-------- .../flavours/glitch/components/status_content.js | 26 ++++----- .../flavours/glitch/components/status_header.js | 4 +- .../flavours/glitch/components/status_icons.js | 22 ++++---- .../flavours/glitch/components/status_list.js | 12 ++-- .../flavours/glitch/components/status_prepend.js | 6 +- 39 files changed, 226 insertions(+), 220 deletions(-) (limited to 'app/javascript/flavours/glitch/components') diff --git a/app/javascript/flavours/glitch/components/account.js b/app/javascript/flavours/glitch/components/account.js index 8e810ce5f..7ce4b65aa 100644 --- a/app/javascript/flavours/glitch/components/account.js +++ b/app/javascript/flavours/glitch/components/account.js @@ -48,27 +48,27 @@ class Account extends ImmutablePureComponent { handleFollow = () => { this.props.onFollow(this.props.account); - } + }; handleBlock = () => { this.props.onBlock(this.props.account); - } + }; handleMute = () => { this.props.onMute(this.props.account); - } + }; handleMuteNotifications = () => { this.props.onMuteNotifications(this.props.account, true); - } + }; handleUnmuteNotifications = () => { this.props.onMuteNotifications(this.props.account, false); - } + }; handleAction = () => { this.props.onActionClick(this.props.account); - } + }; render () { const { diff --git a/app/javascript/flavours/glitch/components/admin/Retention.js b/app/javascript/flavours/glitch/components/admin/Retention.js index 9cc39040b..e1ba3f6c9 100644 --- a/app/javascript/flavours/glitch/components/admin/Retention.js +++ b/app/javascript/flavours/glitch/components/admin/Retention.js @@ -137,7 +137,7 @@ export default class Retention extends React.PureComponent { break; default: title = ; - }; + } return (
diff --git a/app/javascript/flavours/glitch/components/animated_number.js b/app/javascript/flavours/glitch/components/animated_number.js index 9431c96f7..dd21d97f0 100644 --- a/app/javascript/flavours/glitch/components/animated_number.js +++ b/app/javascript/flavours/glitch/components/animated_number.js @@ -38,13 +38,13 @@ export default class AnimatedNumber extends React.PureComponent { const { direction } = this.state; return { y: -1 * direction }; - } + }; willLeave = () => { const { direction } = this.state; return { y: spring(1 * direction, { damping: 35, stiffness: 400 }) }; - } + }; render () { const { value, obfuscate } = this.props; diff --git a/app/javascript/flavours/glitch/components/autosuggest_input.js b/app/javascript/flavours/glitch/components/autosuggest_input.js index c7b024652..4d751e281 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_input.js +++ b/app/javascript/flavours/glitch/components/autosuggest_input.js @@ -78,7 +78,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { } this.props.onChange(e); - } + }; onKeyDown = (e) => { const { suggestions, disabled } = this.props; @@ -136,22 +136,22 @@ export default class AutosuggestInput extends ImmutablePureComponent { } this.props.onKeyDown(e); - } + }; onBlur = () => { this.setState({ suggestionsHidden: true, focused: false }); - } + }; onFocus = () => { this.setState({ focused: true }); - } + }; onSuggestionClick = (e) => { const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index')); e.preventDefault(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.input.focus(); - } + }; componentWillReceiveProps (nextProps) { if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { @@ -161,7 +161,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { setInput = (c) => { this.input = c; - } + }; renderSuggestion = (suggestion, i) => { const { selectedSuggestion } = this.state; @@ -183,7 +183,7 @@ export default class AutosuggestInput extends ImmutablePureComponent { {inner}
); - } + }; render () { const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength, lang } = this.props; diff --git a/app/javascript/flavours/glitch/components/autosuggest_textarea.js b/app/javascript/flavours/glitch/components/autosuggest_textarea.js index 68c083433..6e6e567b9 100644 --- a/app/javascript/flavours/glitch/components/autosuggest_textarea.js +++ b/app/javascript/flavours/glitch/components/autosuggest_textarea.js @@ -75,7 +75,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } this.props.onChange(e); - } + }; onKeyDown = (e) => { const { suggestions, disabled } = this.props; @@ -133,25 +133,25 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { } this.props.onKeyDown(e); - } + }; onBlur = () => { this.setState({ suggestionsHidden: true, focused: false }); - } + }; onFocus = (e) => { this.setState({ focused: true }); if (this.props.onFocus) { this.props.onFocus(e); } - } + }; onSuggestionClick = (e) => { const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index')); e.preventDefault(); this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.textarea.focus(); - } + }; componentWillReceiveProps (nextProps) { if (nextProps.suggestions !== this.props.suggestions && nextProps.suggestions.size > 0 && this.state.suggestionsHidden && this.state.focused) { @@ -161,14 +161,14 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { setTextarea = (c) => { this.textarea = c; - } + }; onPaste = (e) => { if (e.clipboardData && e.clipboardData.files.length === 1) { this.props.onPaste(e.clipboardData.files); e.preventDefault(); } - } + }; renderSuggestion = (suggestion, i) => { const { selectedSuggestion } = this.state; @@ -190,7 +190,7 @@ export default class AutosuggestTextarea extends ImmutablePureComponent { {inner} ); - } + }; render () { const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, lang, children } = this.props; diff --git a/app/javascript/flavours/glitch/components/avatar.js b/app/javascript/flavours/glitch/components/avatar.js index 38fd99af5..f30b33e70 100644 --- a/app/javascript/flavours/glitch/components/avatar.js +++ b/app/javascript/flavours/glitch/components/avatar.js @@ -28,12 +28,12 @@ export default class Avatar extends React.PureComponent { handleMouseEnter = () => { if (this.props.animate) return; this.setState({ hovering: true }); - } + }; handleMouseLeave = () => { if (this.props.animate) return; this.setState({ hovering: false }); - } + }; render () { const { diff --git a/app/javascript/flavours/glitch/components/button.js b/app/javascript/flavours/glitch/components/button.js index b1815c3e1..40b8f5a15 100644 --- a/app/javascript/flavours/glitch/components/button.js +++ b/app/javascript/flavours/glitch/components/button.js @@ -19,11 +19,11 @@ export default class Button extends React.PureComponent { if (!this.props.disabled) { this.props.onClick(e); } - } + }; setRef = (c) => { this.node = c; - } + }; focus() { this.node.focus(); diff --git a/app/javascript/flavours/glitch/components/column.js b/app/javascript/flavours/glitch/components/column.js index cf0e6d5e4..47293ef18 100644 --- a/app/javascript/flavours/glitch/components/column.js +++ b/app/javascript/flavours/glitch/components/column.js @@ -29,11 +29,11 @@ export default class Column extends React.PureComponent { } this._interruptScrollAnimation(); - } + }; setRef = c => { this.node = c; - } + }; componentDidMount () { if (this.props.bindToDocument) { diff --git a/app/javascript/flavours/glitch/components/column_back_button.js b/app/javascript/flavours/glitch/components/column_back_button.js index 05688f867..e9e2615cb 100644 --- a/app/javascript/flavours/glitch/components/column_back_button.js +++ b/app/javascript/flavours/glitch/components/column_back_button.js @@ -26,7 +26,7 @@ export default class ColumnBackButton extends React.PureComponent { } else { this.context.router.history.push('/'); } - } + }; render () { const { multiColumn } = this.props; diff --git a/app/javascript/flavours/glitch/components/column_back_button_slim.js b/app/javascript/flavours/glitch/components/column_back_button_slim.js index faa0c23a8..b43d85b3b 100644 --- a/app/javascript/flavours/glitch/components/column_back_button_slim.js +++ b/app/javascript/flavours/glitch/components/column_back_button_slim.js @@ -21,7 +21,7 @@ export default class ColumnBackButtonSlim extends React.PureComponent { } else { this.context.router.history.push('/'); } - } + }; render () { return ( diff --git a/app/javascript/flavours/glitch/components/column_header.js b/app/javascript/flavours/glitch/components/column_header.js index 0f89b3a97..3790960dd 100644 --- a/app/javascript/flavours/glitch/components/column_header.js +++ b/app/javascript/flavours/glitch/components/column_header.js @@ -55,39 +55,39 @@ class ColumnHeader extends React.PureComponent { } else { this.context.router.history.push('/'); } - } + }; handleToggleClick = (e) => { e.stopPropagation(); this.setState({ collapsed: !this.state.collapsed, animating: true }); - } + }; handleTitleClick = () => { this.props.onClick?.(); - } + }; handleMoveLeft = () => { this.props.onMove(-1); - } + }; handleMoveRight = () => { this.props.onMove(1); - } + }; handleBackClick = (event) => { this.historyBack(event.shiftKey); - } + }; handleTransitionEnd = () => { this.setState({ animating: false }); - } + }; handlePin = () => { if (!this.props.pinned) { this.historyBack(); } this.props.onPin(); - } + }; render () { const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage }, placeholder, appendContent, collapseIssues } = this.props; diff --git a/app/javascript/flavours/glitch/components/dismissable_banner.js b/app/javascript/flavours/glitch/components/dismissable_banner.js index ff52a619d..c4968ac3c 100644 --- a/app/javascript/flavours/glitch/components/dismissable_banner.js +++ b/app/javascript/flavours/glitch/components/dismissable_banner.js @@ -24,7 +24,7 @@ class DismissableBanner extends React.PureComponent { handleDismiss = () => { const { id } = this.props; this.setState({ visible: false }, () => bannerSettings.set(id, true)); - } + }; render () { const { visible } = this.state; diff --git a/app/javascript/flavours/glitch/components/display_name.js b/app/javascript/flavours/glitch/components/display_name.js index 1c2297578..19f63ec60 100644 --- a/app/javascript/flavours/glitch/components/display_name.js +++ b/app/javascript/flavours/glitch/components/display_name.js @@ -27,7 +27,7 @@ export default class DisplayName extends React.PureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-original'); } - } + }; handleMouseLeave = ({ currentTarget }) => { if (autoPlayGif) { @@ -40,7 +40,7 @@ export default class DisplayName extends React.PureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-static'); } - } + }; render() { const { account, className, inline, localDomain, others, onAccountClick } = this.props; @@ -74,7 +74,7 @@ export default class DisplayName extends React.PureComponent { )).reduce((prev, cur) => [prev, ', ', cur]); if (others.size - 2 > 0) { - displayName.push(` +${others.size - 2}`); + displayName.push(` +${others.size - 2}`); } suffix = ( diff --git a/app/javascript/flavours/glitch/components/domain.js b/app/javascript/flavours/glitch/components/domain.js index 697065d87..e09fa4591 100644 --- a/app/javascript/flavours/glitch/components/domain.js +++ b/app/javascript/flavours/glitch/components/domain.js @@ -19,7 +19,7 @@ class Account extends ImmutablePureComponent { handleDomainUnblock = () => { this.props.onUnblockDomain(this.props.domain); - } + }; render () { const { domain, intl } = this.props; diff --git a/app/javascript/flavours/glitch/components/dropdown_menu.js b/app/javascript/flavours/glitch/components/dropdown_menu.js index 7c70f750f..f4b6e059f 100644 --- a/app/javascript/flavours/glitch/components/dropdown_menu.js +++ b/app/javascript/flavours/glitch/components/dropdown_menu.js @@ -36,7 +36,7 @@ class DropdownMenu extends React.PureComponent { if (this.node && !this.node.contains(e.target)) { this.props.onClose(); } - } + }; componentDidMount () { document.addEventListener('click', this.handleDocumentClick, false); @@ -56,11 +56,11 @@ class DropdownMenu extends React.PureComponent { setRef = c => { this.node = c; - } + }; setFocusRef = c => { this.focusedItem = c; - } + }; handleKeyDown = e => { const items = Array.from(this.node.querySelectorAll('a, button')); @@ -97,18 +97,18 @@ class DropdownMenu extends React.PureComponent { e.preventDefault(); e.stopPropagation(); } - } + }; handleItemKeyPress = e => { if (e.key === 'Enter' || e.key === ' ') { this.handleClick(e); } - } + }; handleClick = e => { const { onItemClick } = this.props; onItemClick(e); - } + }; renderItem = (option, i) => { if (option === null) { @@ -124,7 +124,7 @@ class DropdownMenu extends React.PureComponent { ); - } + }; render () { const { items, scrollable, renderHeader, loading } = this.props; @@ -194,7 +194,7 @@ export default class Dropdown extends React.PureComponent { } else { this.props.onOpen(this.state.id, this.handleItemClick, type !== 'click'); } - } + }; handleClose = () => { if (this.activeElement) { @@ -202,13 +202,13 @@ export default class Dropdown extends React.PureComponent { this.activeElement = null; } this.props.onClose(this.state.id); - } + }; handleMouseDown = () => { if (!this.state.open) { this.activeElement = document.activeElement; } - } + }; handleButtonKeyDown = (e) => { switch(e.key) { @@ -217,7 +217,7 @@ export default class Dropdown extends React.PureComponent { this.handleMouseDown(); break; } - } + }; handleKeyPress = (e) => { switch(e.key) { @@ -228,7 +228,7 @@ export default class Dropdown extends React.PureComponent { e.preventDefault(); break; } - } + }; handleItemClick = e => { const { onItemClick } = this.props; @@ -247,25 +247,25 @@ export default class Dropdown extends React.PureComponent { e.preventDefault(); this.context.router.history.push(item.to); } - } + }; setTargetRef = c => { this.target = c; - } + }; findTarget = () => { return this.target; - } + }; componentWillUnmount = () => { if (this.state.id === this.props.openDropdownId) { this.handleClose(); } - } + }; close = () => { this.handleClose(); - } + }; render () { const { diff --git a/app/javascript/flavours/glitch/components/edited_timestamp/index.js b/app/javascript/flavours/glitch/components/edited_timestamp/index.js index 9648133af..c973bda58 100644 --- a/app/javascript/flavours/glitch/components/edited_timestamp/index.js +++ b/app/javascript/flavours/glitch/components/edited_timestamp/index.js @@ -36,7 +36,7 @@ class EditedTimestamp extends React.PureComponent { return ( ); - } + }; renderItem = (item, index, { onClick, onKeyPress }) => { const formattedDate = ; @@ -53,7 +53,7 @@ class EditedTimestamp extends React.PureComponent { ); - } + }; render () { const { timestamp, intl, statusId } = this.props; diff --git a/app/javascript/flavours/glitch/components/error_boundary.js b/app/javascript/flavours/glitch/components/error_boundary.js index e0ca3e2b0..8518dfc86 100644 --- a/app/javascript/flavours/glitch/components/error_boundary.js +++ b/app/javascript/flavours/glitch/components/error_boundary.js @@ -18,7 +18,7 @@ export default class ErrorBoundary extends React.PureComponent { stackTrace: undefined, mappedStackTrace: undefined, componentStack: undefined, - } + }; componentDidCatch(error, info) { this.setState({ diff --git a/app/javascript/flavours/glitch/components/gifv.js b/app/javascript/flavours/glitch/components/gifv.js index b775e5200..1f0f99b46 100644 --- a/app/javascript/flavours/glitch/components/gifv.js +++ b/app/javascript/flavours/glitch/components/gifv.js @@ -17,7 +17,7 @@ export default class GIFV extends React.PureComponent { handleLoadedData = () => { this.setState({ loading: false }); - } + }; componentWillReceiveProps (nextProps) { if (nextProps.src !== this.props.src) { @@ -32,7 +32,7 @@ export default class GIFV extends React.PureComponent { e.stopPropagation(); onClick(); } - } + }; render () { const { src, width, height, alt } = this.props; diff --git a/app/javascript/flavours/glitch/components/icon_button.js b/app/javascript/flavours/glitch/components/icon_button.js index 2485f0f48..10d7926be 100644 --- a/app/javascript/flavours/glitch/components/icon_button.js +++ b/app/javascript/flavours/glitch/components/icon_button.js @@ -46,7 +46,7 @@ export default class IconButton extends React.PureComponent { state = { activate: false, deactivate: false, - } + }; componentWillReceiveProps (nextProps) { if (!nextProps.animate) return; @@ -64,25 +64,25 @@ export default class IconButton extends React.PureComponent { if (!this.props.disabled) { this.props.onClick(e); } - } + }; handleKeyPress = (e) => { if (this.props.onKeyPress && !this.props.disabled) { this.props.onKeyPress(e); } - } + }; handleMouseDown = (e) => { if (!this.props.disabled && this.props.onMouseDown) { this.props.onMouseDown(e); } - } + }; handleKeyDown = (e) => { if (!this.props.disabled && this.props.onKeyDown) { this.props.onKeyDown(e); } - } + }; render () { // Hack required for some icons which have an overriden size diff --git a/app/javascript/flavours/glitch/components/intersection_observer_article.js b/app/javascript/flavours/glitch/components/intersection_observer_article.js index b28e44e4c..77cd66358 100644 --- a/app/javascript/flavours/glitch/components/intersection_observer_article.js +++ b/app/javascript/flavours/glitch/components/intersection_observer_article.js @@ -21,7 +21,7 @@ export default class IntersectionObserverArticle extends React.Component { state = { isHidden: false, // set to true in requestIdleCallback to trigger un-render - } + }; shouldComponentUpdate (nextProps, nextState) { const isUnrendered = !this.state.isIntersecting && (this.state.isHidden || this.props.cachedHeight); @@ -63,7 +63,7 @@ export default class IntersectionObserverArticle extends React.Component { scheduleIdleTask(this.calculateHeight); this.setState(this.updateStateAfterIntersection); - } + }; updateStateAfterIntersection = (prevState) => { if (prevState.isIntersecting !== false && !this.entry.isIntersecting) { @@ -73,7 +73,7 @@ export default class IntersectionObserverArticle extends React.Component { isIntersecting: this.entry.isIntersecting, isHidden: false, }; - } + }; calculateHeight = () => { const { onHeightChange, saveHeightKey, id } = this.props; @@ -84,7 +84,7 @@ export default class IntersectionObserverArticle extends React.Component { if (onHeightChange && saveHeightKey) { onHeightChange(saveHeightKey, id, this.height); } - } + }; hideIfNotIntersecting = () => { if (!this.componentMounted) { @@ -96,11 +96,11 @@ export default class IntersectionObserverArticle extends React.Component { // this is to save DOM nodes and avoid using up too much memory. // See: https://github.com/mastodon/mastodon/issues/2900 this.setState((prevState) => ({ isHidden: !prevState.isIntersecting })); - } + }; handleRef = (node) => { this.node = node; - } + }; render () { const { children, id, index, listLength, cachedHeight } = this.props; @@ -121,8 +121,9 @@ export default class IntersectionObserverArticle extends React.Component { aria-setsize={listLength} data-id={id} tabIndex='0' - style={style}> - {children && React.cloneElement(children, { hidden: !isIntersecting && (isHidden || !!cachedHeight) })} + style={style} + > + {children && React.cloneElement(children, { hidden: !isIntersecting && (isHidden || !!cachedHeight) })} ); } diff --git a/app/javascript/flavours/glitch/components/load_gap.js b/app/javascript/flavours/glitch/components/load_gap.js index fe3f60a58..6ed9a38c6 100644 --- a/app/javascript/flavours/glitch/components/load_gap.js +++ b/app/javascript/flavours/glitch/components/load_gap.js @@ -19,7 +19,7 @@ class LoadGap extends React.PureComponent { handleClick = () => { this.props.onClick(this.props.maxId); - } + }; render () { const { disabled, intl } = this.props; diff --git a/app/javascript/flavours/glitch/components/load_more.js b/app/javascript/flavours/glitch/components/load_more.js index 389c3e1e1..ab9428e35 100644 --- a/app/javascript/flavours/glitch/components/load_more.js +++ b/app/javascript/flavours/glitch/components/load_more.js @@ -8,11 +8,11 @@ export default class LoadMore extends React.PureComponent { onClick: PropTypes.func, disabled: PropTypes.bool, visible: PropTypes.bool, - } + }; static defaultProps = { visible: true, - } + }; render() { const { disabled, visible } = this.props; diff --git a/app/javascript/flavours/glitch/components/load_pending.js b/app/javascript/flavours/glitch/components/load_pending.js index 7e2702403..a75259146 100644 --- a/app/javascript/flavours/glitch/components/load_pending.js +++ b/app/javascript/flavours/glitch/components/load_pending.js @@ -7,7 +7,7 @@ export default class LoadPending extends React.PureComponent { static propTypes = { onClick: PropTypes.func, count: PropTypes.number, - } + }; render() { const { count } = this.props; diff --git a/app/javascript/flavours/glitch/components/media_attachments.js b/app/javascript/flavours/glitch/components/media_attachments.js index a517fcf30..33f01bb5a 100644 --- a/app/javascript/flavours/glitch/components/media_attachments.js +++ b/app/javascript/flavours/glitch/components/media_attachments.js @@ -30,7 +30,7 @@ export default class MediaAttachments extends ImmutablePureComponent { return (
); - } + }; renderLoadingVideoPlayer = () => { const { height, width } = this.props; @@ -38,7 +38,7 @@ export default class MediaAttachments extends ImmutablePureComponent { return (
); - } + }; renderLoadingAudioPlayer = () => { const { height, width } = this.props; @@ -46,7 +46,7 @@ export default class MediaAttachments extends ImmutablePureComponent { return (
); - } + }; render () { const { status, width, height, revealed } = this.props; diff --git a/app/javascript/flavours/glitch/components/media_gallery.js b/app/javascript/flavours/glitch/components/media_gallery.js index 23e279589..c11ac46c2 100644 --- a/app/javascript/flavours/glitch/components/media_gallery.js +++ b/app/javascript/flavours/glitch/components/media_gallery.js @@ -60,14 +60,14 @@ class Item extends React.PureComponent { if (this.hoverToPlay()) { e.target.play(); } - } + }; handleMouseLeave = (e) => { if (this.hoverToPlay()) { e.target.pause(); e.target.currentTime = 0; } - } + }; getAutoPlay() { return this.props.autoplay || autoPlayGif; @@ -91,11 +91,11 @@ class Item extends React.PureComponent { } e.stopPropagation(); - } + }; handleImageLoad = () => { this.setState({ loaded: true }); - } + }; render () { const { attachment, index, size, standalone, letterbox, displayWidth, visible } = this.props; @@ -307,11 +307,11 @@ class MediaGallery extends React.PureComponent { } else { this.setState({ visible: !this.state.visible }); } - } + }; handleClick = (index) => { this.props.onOpenMedia(this.props.media, index); - } + }; handleRef = (node) => { this.node = node; @@ -319,11 +319,11 @@ class MediaGallery extends React.PureComponent { if (this.node) { this._setDimensions(); } - } + }; _setDimensions () { const width = this.node.offsetWidth; - + if (width && width != this.state.width) { // offsetWidth triggers a layout, so only calculate when we need to if (this.props.cacheWidth) { @@ -360,7 +360,7 @@ class MediaGallery extends React.PureComponent { } else if (width) { style.height = width / (16/9); } else { - return (
); + return (
); } if (this.isStandaloneEligible()) { diff --git a/app/javascript/flavours/glitch/components/modal_root.js b/app/javascript/flavours/glitch/components/modal_root.js index 056277447..5a5563e87 100644 --- a/app/javascript/flavours/glitch/components/modal_root.js +++ b/app/javascript/flavours/glitch/components/modal_root.js @@ -5,6 +5,7 @@ import { createBrowserHistory } from 'history'; import { multiply } from 'color-blend'; export default class ModalRoot extends React.PureComponent { + static contextTypes = { router: PropTypes.object, }; @@ -28,7 +29,7 @@ export default class ModalRoot extends React.PureComponent { && !!this.props.children && !this.props.noEsc) { this.props.onClose(); } - } + }; handleKeyDown = (e) => { if (e.key === 'Tab') { @@ -49,7 +50,7 @@ export default class ModalRoot extends React.PureComponent { e.preventDefault(); } } - } + }; componentDidMount () { window.addEventListener('keyup', this.handleKeyUp, false); @@ -125,11 +126,11 @@ export default class ModalRoot extends React.PureComponent { getSiblings = () => { return Array(...this.node.parentElement.childNodes).filter(node => node !== this.node); - } + }; setRef = ref => { this.node = ref; - } + }; render () { const { children, onClose } = this.props; diff --git a/app/javascript/flavours/glitch/components/permalink.js b/app/javascript/flavours/glitch/components/permalink.js index 718b02115..b09b17eeb 100644 --- a/app/javascript/flavours/glitch/components/permalink.js +++ b/app/javascript/flavours/glitch/components/permalink.js @@ -24,12 +24,12 @@ export default class Permalink extends React.PureComponent { if (this.context.router) { e.preventDefault(); - let state = {...this.context.router.history.location.state}; + let state = { ...this.context.router.history.location.state }; state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1; this.context.router.history.push(this.props.to, state); } } - } + }; render () { const { diff --git a/app/javascript/flavours/glitch/components/picture_in_picture_placeholder.js b/app/javascript/flavours/glitch/components/picture_in_picture_placeholder.js index 01dce0a38..8bfdf343c 100644 --- a/app/javascript/flavours/glitch/components/picture_in_picture_placeholder.js +++ b/app/javascript/flavours/glitch/components/picture_in_picture_placeholder.js @@ -22,7 +22,7 @@ class PictureInPicturePlaceholder extends React.PureComponent { handleClick = () => { const { dispatch } = this.props; dispatch(removePictureInPicture()); - } + }; setRef = c => { this.node = c; @@ -30,7 +30,7 @@ class PictureInPicturePlaceholder extends React.PureComponent { if (this.node) { this._setDimensions(); } - } + }; _setDimensions () { const width = this.node.offsetWidth; diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js index da65cd241..53ece560e 100644 --- a/app/javascript/flavours/glitch/components/poll.js +++ b/app/javascript/flavours/glitch/components/poll.js @@ -95,7 +95,7 @@ class Poll extends ImmutablePureComponent { tmp[value] = true; this.setState({ selected: tmp }); } - } + }; handleOptionChange = ({ target: { value } }) => { this._toggleOption(value); @@ -107,7 +107,7 @@ class Poll extends ImmutablePureComponent { e.stopPropagation(); e.preventDefault(); } - } + }; handleVote = () => { if (this.props.disabled) { diff --git a/app/javascript/flavours/glitch/components/scrollable_list.js b/app/javascript/flavours/glitch/components/scrollable_list.js index 8eb2b66d4..ae1ba3037 100644 --- a/app/javascript/flavours/glitch/components/scrollable_list.js +++ b/app/javascript/flavours/glitch/components/scrollable_list.js @@ -137,7 +137,7 @@ class ScrollableList extends PureComponent { } this.mouseMovedRecently = false; this.scrollToTopOnMouseIdle = false; - } + }; componentDidMount () { this.attachScrollListener(); @@ -154,29 +154,29 @@ class ScrollableList extends PureComponent { } else { return null; } - } + }; getScrollTop = () => { return this.props.bindToDocument ? document.scrollingElement.scrollTop : this.node.scrollTop; - } + }; getScrollHeight = () => { return this.props.bindToDocument ? document.scrollingElement.scrollHeight : this.node.scrollHeight; - } + }; getClientHeight = () => { return this.props.bindToDocument ? document.scrollingElement.clientHeight : this.node.clientHeight; - } + }; updateScrollBottom = (snapshot) => { const newScrollTop = this.getScrollHeight() - snapshot; this.setScrollTop(newScrollTop); - } + }; cacheMediaWidth = (width) => { if (width && this.state.cachedMediaWidth != width) this.setState({ cachedMediaWidth: width }); - } + }; getSnapshotBeforeUpdate (prevProps, prevState) { const someItemInserted = React.Children.count(prevProps.children) > 0 && @@ -208,7 +208,7 @@ class ScrollableList extends PureComponent { onFullScreenChange = () => { this.setState({ fullscreen: isFullscreen() }); - } + }; attachIntersectionObserver () { this.intersectionObserverWrapper.connect({ @@ -256,12 +256,12 @@ class ScrollableList extends PureComponent { setRef = (c) => { this.node = c; - } + }; handleLoadMore = e => { e.preventDefault(); this.props.onLoadMore(); - } + }; handleLoadPending = e => { e.preventDefault(); @@ -273,7 +273,7 @@ class ScrollableList extends PureComponent { this.clearMouseIdleTimer(); this.mouseIdleTimer = setTimeout(this.handleMouseIdle, MOUSE_IDLE_DELAY); this.mouseMovedRecently = true; - } + }; render () { const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, emptyMessage, onLoadMore } = this.props; diff --git a/app/javascript/flavours/glitch/components/setting_text.js b/app/javascript/flavours/glitch/components/setting_text.js index 2c1b70bc3..3a21a0601 100644 --- a/app/javascript/flavours/glitch/components/setting_text.js +++ b/app/javascript/flavours/glitch/components/setting_text.js @@ -13,7 +13,7 @@ export default class SettingText extends React.PureComponent { handleChange = (e) => { this.props.onChange(this.props.settingPath, e.target.value); - } + }; render () { const { settings, settingPath, label } = this.props; diff --git a/app/javascript/flavours/glitch/components/spoilers.js b/app/javascript/flavours/glitch/components/spoilers.js index 8527403c1..75e4ec3a1 100644 --- a/app/javascript/flavours/glitch/components/spoilers.js +++ b/app/javascript/flavours/glitch/components/spoilers.js @@ -4,6 +4,7 @@ import { FormattedMessage } from 'react-intl'; export default class Spoilers extends React.PureComponent { + static propTypes = { spoilerText: PropTypes.string, children: PropTypes.node, @@ -11,27 +12,27 @@ class Spoilers extends React.PureComponent { state = { hidden: true, - } + }; handleSpoilerClick = () => { this.setState({ hidden: !this.state.hidden }); - } + }; render () { const { spoilerText, children } = this.props; const { hidden } = this.state; - const toggleText = hidden ? - : - ; + const toggleText = hidden ? + () : + (); return ([

@@ -43,8 +44,9 @@ class Spoilers extends React.PureComponent {

,
{children} -
+
, ]); } + } diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index cbd8eb31c..34880efe4 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -54,7 +54,7 @@ export const defaultMediaVisibility = (status, settings) => { } return (displayMedia !== 'hide_all' && !status.get('sensitive') || displayMedia === 'show_all'); -} +}; export default @injectIntl class Status extends ImmutablePureComponent { @@ -117,7 +117,7 @@ class Status extends ImmutablePureComponent { revealBehindCW: undefined, showCard: false, forceFilter: undefined, - } + }; // Avoid checking props that are functions (and whose equality will always // evaluate to false. See react-immutable-pure-component for usage. @@ -132,14 +132,14 @@ class Status extends ImmutablePureComponent { 'expanded', 'unread', 'pictureInPicture', - ] + ]; updateOnStates = [ 'isExpanded', 'isCollapsed', 'showMedia', 'forceFilter', - ] + ]; // If our settings have changed to disable collapsed statuses, then we // need to make sure that we uncollapse every one. We do that by watching @@ -302,7 +302,9 @@ class Status extends ImmutablePureComponent { if (this.node && this.props.getScrollPosition) { const position = this.props.getScrollPosition(); if (position !== null && this.node.offsetTop < position.top) { - requestAnimationFrame(() => { this.props.updateScrollBottom(position.height - position.top); }); + requestAnimationFrame(() => { + this.props.updateScrollBottom(position.height - position.top); + }); } } } @@ -321,7 +323,7 @@ class Status extends ImmutablePureComponent { } else { this.setState({ isCollapsed: false }); } - } + }; setExpansion = (value) => { if (this.props.settings.getIn(['content_warnings', 'shared_state']) && this.props.status.get('hidden') === value) { @@ -332,7 +334,7 @@ class Status extends ImmutablePureComponent { if (value) { this.setCollapsed(false); } - } + }; // `parseClick()` takes a click event and responds appropriately. // If our status is collapsed, then clicking on it should uncollapse it. @@ -361,17 +363,17 @@ class Status extends ImmutablePureComponent { status.getIn(['reblog', 'id'], status.get('id')) }`; } - let state = {...router.history.location.state}; + let state = { ...router.history.location.state }; state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1; router.history.push(destination, state); } e.preventDefault(); } - } + }; handleToggleMediaVisibility = () => { this.setState({ showMedia: !this.state.showMedia }); - } + }; handleExpandedToggle = () => { if (this.props.settings.getIn(['content_warnings', 'shared_state'])) { @@ -384,11 +386,11 @@ class Status extends ImmutablePureComponent { handleOpenVideo = (options) => { const { status } = this.props; this.props.onOpenVideo(status.get('id'), status.getIn(['media_attachments', 0]), options); - } + }; handleOpenMedia = (media, index) => { this.props.onOpenMedia(this.props.status.get('id'), media, index); - } + }; handleHotkeyOpenMedia = e => { const { status, onOpenMedia, onOpenVideo } = this.props; @@ -403,84 +405,84 @@ class Status extends ImmutablePureComponent { onOpenMedia(statusId, status.get('media_attachments'), 0); } } - } + }; handleDeployPictureInPicture = (type, mediaProps) => { const { deployPictureInPicture, status } = this.props; deployPictureInPicture(status, type, mediaProps); - } + }; handleHotkeyReply = e => { e.preventDefault(); this.props.onReply(this.props.status, this.context.router.history); - } + }; handleHotkeyFavourite = (e) => { this.props.onFavourite(this.props.status, e); - } + }; handleHotkeyBoost = e => { this.props.onReblog(this.props.status, e); - } + }; handleHotkeyBookmark = e => { this.props.onBookmark(this.props.status, e); - } + }; handleHotkeyMention = e => { e.preventDefault(); this.props.onMention(this.props.status.get('account'), this.context.router.history); - } + }; handleHotkeyOpen = () => { - let state = {...this.context.router.history.location.state}; + let state = { ...this.context.router.history.location.state }; state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1; const status = this.props.status; this.context.router.history.push(`/@${status.getIn(['account', 'acct'])}/${status.get('id')}`, state); - } + }; handleHotkeyOpenProfile = () => { - let state = {...this.context.router.history.location.state}; + let state = { ...this.context.router.history.location.state }; state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1; this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`, state); - } + }; handleHotkeyMoveUp = e => { this.props.onMoveUp(this.props.containerId || this.props.id, e.target.getAttribute('data-featured')); - } + }; handleHotkeyMoveDown = e => { this.props.onMoveDown(this.props.containerId || this.props.id, e.target.getAttribute('data-featured')); - } + }; handleHotkeyCollapse = e => { if (!this.props.settings.getIn(['collapsed', 'enabled'])) return; this.setCollapsed(!this.state.isCollapsed); - } + }; handleHotkeyToggleSensitive = () => { this.handleToggleMediaVisibility(); - } + }; handleUnfilterClick = e => { this.setState({ forceFilter: false }); e.preventDefault(); - } + }; handleFilterClick = () => { this.setState({ forceFilter: true }); - } + }; handleRef = c => { this.node = c; - } + }; handleTranslate = () => { this.props.onTranslate(this.props.status); - } + }; renderLoadingMediaGallery () { return
; diff --git a/app/javascript/flavours/glitch/components/status_action_bar.js b/app/javascript/flavours/glitch/components/status_action_bar.js index baf61000a..02c5442b5 100644 --- a/app/javascript/flavours/glitch/components/status_action_bar.js +++ b/app/javascript/flavours/glitch/components/status_action_bar.js @@ -86,7 +86,7 @@ class StatusActionBar extends ImmutablePureComponent { 'showReplyCount', 'withCounters', 'withDismiss', - ] + ]; handleReplyClick = () => { const { signedIn } = this.context.identity; @@ -96,14 +96,14 @@ class StatusActionBar extends ImmutablePureComponent { } else { this.props.onInteractionModal('reply', this.props.status); } - } + }; handleShareClick = () => { navigator.share({ text: this.props.status.get('search_index'), url: this.props.status.get('url'), }); - } + }; handleFavouriteClick = (e) => { const { signedIn } = this.context.identity; @@ -113,7 +113,7 @@ class StatusActionBar extends ImmutablePureComponent { } else { this.props.onInteractionModal('favourite', this.props.status); } - } + }; handleReblogClick = e => { const { signedIn } = this.context.identity; @@ -123,78 +123,78 @@ class StatusActionBar extends ImmutablePureComponent { } else { this.props.onInteractionModal('reblog', this.props.status); } - } + }; handleBookmarkClick = (e) => { this.props.onBookmark(this.props.status, e); - } + }; handleDeleteClick = () => { this.props.onDelete(this.props.status, this.context.router.history); - } + }; handleRedraftClick = () => { this.props.onDelete(this.props.status, this.context.router.history, true); - } + }; handleEditClick = () => { this.props.onEdit(this.props.status, this.context.router.history); - } + }; handlePinClick = () => { this.props.onPin(this.props.status); - } + }; handleMentionClick = () => { this.props.onMention(this.props.status.get('account'), this.context.router.history); - } + }; handleDirectClick = () => { this.props.onDirect(this.props.status.get('account'), this.context.router.history); - } + }; handleMuteClick = () => { this.props.onMute(this.props.status.get('account')); - } + }; handleBlockClick = () => { this.props.onBlock(this.props.status); - } + }; handleOpen = () => { - let state = {...this.context.router.history.location.state}; + let state = { ...this.context.router.history.location.state }; if (state.mastodonModalKey) { this.context.router.history.replace(`/@${this.props.status.getIn(['account', 'acct'])}/${this.props.status.get('id')}`, { mastodonBackSteps: (state.mastodonBackSteps || 0) + 1 }); } else { state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1; this.context.router.history.push(`/@${this.props.status.getIn(['account', 'acct'])}/${this.props.status.get('id')}`, state); } - } + }; handleEmbed = () => { this.props.onEmbed(this.props.status); - } + }; handleReport = () => { this.props.onReport(this.props.status); - } + }; handleConversationMuteClick = () => { this.props.onMuteConversation(this.props.status); - } + }; handleCopy = () => { const url = this.props.status.get('url'); navigator.clipboard.writeText(url); - } + }; handleHideClick = () => { this.props.onFilter(); - } + }; handleFilterClick = () => { this.props.onAddFilter(this.props.status); - } + }; render () { const { status, intl, withDismiss, withCounters, showReplyCount, scrollKey } = this.props; diff --git a/app/javascript/flavours/glitch/components/status_content.js b/app/javascript/flavours/glitch/components/status_content.js index c59f42220..790a5c659 100644 --- a/app/javascript/flavours/glitch/components/status_content.js +++ b/app/javascript/flavours/glitch/components/status_content.js @@ -12,7 +12,7 @@ const textMatchesTarget = (text, origin, host) => { return (text === origin || text === host || text.startsWith(origin + '/') || text.startsWith(host + '/') || 'www.' + text === host || ('www.' + text).startsWith(host + '/')); -} +}; const isLinkMisleading = (link) => { let linkTextParts = []; @@ -168,8 +168,8 @@ class StatusContent extends React.PureComponent { link.setAttribute('title', link.href); link.classList.add('unhandled-link'); - link.setAttribute('target', '_blank'); - link.setAttribute('rel', 'noopener nofollow noreferrer'); + link.setAttribute('target', '_blank'); + link.setAttribute('rel', 'noopener nofollow noreferrer'); try { if (tagLinks && isLinkMisleading(link)) { @@ -210,7 +210,7 @@ class StatusContent extends React.PureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-original'); } - } + }; handleMouseLeave = ({ currentTarget }) => { if (autoPlayGif) { @@ -223,7 +223,7 @@ class StatusContent extends React.PureComponent { let emoji = emojis[i]; emoji.src = emoji.getAttribute('data-static'); } - } + }; componentDidMount () { this._updateStatusLinks(); @@ -238,13 +238,13 @@ class StatusContent extends React.PureComponent { if (this.props.collapsed) { if (this.props.parseClick) this.props.parseClick(e); } - } + }; onMentionClick = (mention, e) => { if (this.props.parseClick) { this.props.parseClick(e, `/@${mention.get('acct')}`); } - } + }; onHashtagClick = (hashtag, e) => { hashtag = hashtag.replace(/^#/, ''); @@ -252,11 +252,11 @@ class StatusContent extends React.PureComponent { if (this.props.parseClick) { this.props.parseClick(e, `/tags/${hashtag}`); } - } + }; handleMouseDown = (e) => { this.startXY = [e.clientX, e.clientY]; - } + }; handleMouseUp = (e) => { const { parseClick, disabled } = this.props; @@ -281,7 +281,7 @@ class StatusContent extends React.PureComponent { } this.startXY = null; - } + }; handleSpoilerClick = (e) => { e.preventDefault(); @@ -291,15 +291,15 @@ class StatusContent extends React.PureComponent { } else { this.setState({ hidden: !this.state.hidden }); } - } + }; handleTranslate = () => { this.props.onTranslate(); - } + }; setContentsRef = (c) => { this.contentsNode = c; - } + }; render () { const { diff --git a/app/javascript/flavours/glitch/components/status_header.js b/app/javascript/flavours/glitch/components/status_header.js index 990dea536..21d8b4212 100644 --- a/app/javascript/flavours/glitch/components/status_header.js +++ b/app/javascript/flavours/glitch/components/status_header.js @@ -21,12 +21,12 @@ export default class StatusHeader extends React.PureComponent { handleClick = (acct, e) => { const { parseClick } = this.props; parseClick(e, `/@${acct}`); - } + }; handleAccountClick = (e) => { const { status } = this.props; this.handleClick(status.getIn(['account', 'acct']), e); - } + }; // Rendering. render () { diff --git a/app/javascript/flavours/glitch/components/status_icons.js b/app/javascript/flavours/glitch/components/status_icons.js index 71ffb2e56..c4cb42741 100644 --- a/app/javascript/flavours/glitch/components/status_icons.js +++ b/app/javascript/flavours/glitch/components/status_icons.js @@ -60,22 +60,22 @@ class StatusIcons extends React.PureComponent { setCollapsed(!collapsed); e.preventDefault(); } - } + }; mediaIconTitleText (mediaIcon) { const { intl } = this.props; switch (mediaIcon) { - case 'link': - return intl.formatMessage(messages.previewCard); - case 'picture-o': - return intl.formatMessage(messages.pictures); - case 'tasks': - return intl.formatMessage(messages.poll); - case 'video-camera': - return intl.formatMessage(messages.video); - case 'music': - return intl.formatMessage(messages.audio); + case 'link': + return intl.formatMessage(messages.previewCard); + case 'picture-o': + return intl.formatMessage(messages.pictures); + case 'tasks': + return intl.formatMessage(messages.poll); + case 'video-camera': + return intl.formatMessage(messages.video); + case 'music': + return intl.formatMessage(messages.audio); } } diff --git a/app/javascript/flavours/glitch/components/status_list.js b/app/javascript/flavours/glitch/components/status_list.js index 0d843a27d..a9c06f693 100644 --- a/app/javascript/flavours/glitch/components/status_list.js +++ b/app/javascript/flavours/glitch/components/status_list.js @@ -35,7 +35,7 @@ export default class StatusList extends ImmutablePureComponent { getFeaturedStatusCount = () => { return this.props.featuredStatusIds ? this.props.featuredStatusIds.size : 0; - } + }; getCurrentStatusIndex = (id, featured) => { if (featured) { @@ -43,21 +43,21 @@ export default class StatusList extends ImmutablePureComponent { } else { return this.props.statusIds.indexOf(id) + this.getFeaturedStatusCount(); } - } + }; handleMoveUp = (id, featured) => { const elementIndex = this.getCurrentStatusIndex(id, featured) - 1; this._selectChild(elementIndex, true); - } + }; handleMoveDown = (id, featured) => { const elementIndex = this.getCurrentStatusIndex(id, featured) + 1; this._selectChild(elementIndex, false); - } + }; handleLoadOlder = debounce(() => { this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined); - }, 300, { leading: true }) + }, 300, { leading: true }); _selectChild (index, align_top) { const container = this.node.node; @@ -75,7 +75,7 @@ export default class StatusList extends ImmutablePureComponent { setRef = c => { this.node = c; - } + }; render () { const { statusIds, featuredStatusIds, onLoadMore, timelineId, ...other } = this.props; diff --git a/app/javascript/flavours/glitch/components/status_prepend.js b/app/javascript/flavours/glitch/components/status_prepend.js index f82533062..8c4343b04 100644 --- a/app/javascript/flavours/glitch/components/status_prepend.js +++ b/app/javascript/flavours/glitch/components/status_prepend.js @@ -18,7 +18,7 @@ export default class StatusPrepend extends React.PureComponent { handleClick = (e) => { const { account, parseClick } = this.props; parseClick(e, `/@${account.get('acct')}`); - } + }; Message = () => { const { type, account } = this.props; @@ -98,7 +98,7 @@ export default class StatusPrepend extends React.PureComponent { ); } return null; - } + }; render () { const { Message } = this; @@ -126,7 +126,7 @@ export default class StatusPrepend extends React.PureComponent { case 'update': iconId = 'pencil'; break; - }; + } return !type ? null : (