From 12e8bcac9d5a6f54d0226effdb5a237d480313d7 Mon Sep 17 00:00:00 2001
From: Claire
Date: Sun, 7 May 2023 21:43:25 +0200
Subject: [PATCH] Fix some more Javascript linting issues and discrepancies
with upstream (#2209)
* Fix typo in flavours/glitch/features/video/index.js
* Fix various linting issues and discrepancies with upstream
---
app/javascript/core/public.js | 2 -
.../flavours/glitch/actions/accounts.js | 2 +-
.../flavours/glitch/actions/timelines.js | 11 ++--
.../glitch/components/avatar_composite.jsx | 1 +
.../glitch/components/display_name.jsx | 2 +
.../glitch/components/icon_button.jsx | 7 ++-
.../glitch/components/media_gallery.jsx | 4 +-
.../flavours/glitch/components/spoilers.jsx | 52 -------------------
.../flavours/glitch/components/status.jsx | 9 ++--
.../glitch/components/status_header.jsx | 1 -
.../glitch/components/status_icons.jsx | 21 ++++----
.../glitch/containers/domain_container.jsx | 3 +-
.../glitch/containers/status_container.js | 7 +--
.../account/components/action_bar.jsx | 11 ++--
.../glitch/features/account_gallery/index.jsx | 3 +-
.../containers/header_container.jsx | 4 --
.../features/account_timeline/index.jsx | 1 -
.../flavours/glitch/features/audio/index.jsx | 2 +-
.../compose/components/compose_form.jsx | 24 ++++-----
.../features/compose/components/dropdown.jsx | 9 ++--
.../compose/components/dropdown_menu.jsx | 10 ++--
.../features/compose/components/poll_form.jsx | 1 +
.../compose/components/privacy_dropdown.jsx | 1 -
.../features/compose/components/search.jsx | 4 +-
.../features/compose/components/upload.jsx | 1 -
.../glitch/features/compose/index.jsx | 5 +-
.../glitch/features/getting_started/index.jsx | 7 +--
.../features/getting_started_misc/index.jsx | 4 +-
.../containers/account_container.js | 1 -
.../containers/search_container.js | 1 -
.../glitch/features/list_timeline/index.jsx | 10 ++--
.../page/deprecated_item/index.jsx | 2 +-
.../local_settings/page/item/index.jsx | 5 +-
.../notifications/components/admin_report.jsx | 9 +---
.../containers/follow_request_container.js | 1 -
.../glitch/features/notifications/index.jsx | 45 ++++++----------
.../containers/account_container.js | 1 -
.../containers/search_container.js | 1 -
.../flavours/glitch/features/video/index.jsx | 2 +-
39 files changed, 87 insertions(+), 200 deletions(-)
delete mode 100644 app/javascript/flavours/glitch/components/spoilers.jsx
diff --git a/app/javascript/core/public.js b/app/javascript/core/public.js
index 5c7a51f447..4fdda5c3e6 100644
--- a/app/javascript/core/public.js
+++ b/app/javascript/core/public.js
@@ -1,10 +1,8 @@
// This file will be loaded on public pages, regardless of theme.
import 'packs/public-path';
-import ready from '../mastodon/ready';
const { delegate } = require('@rails/ujs');
-const { length } = require('stringz');
const getProfileAvatarAnimationHandler = (swapTo) => {
//animate avatar gifs on the profile page when moused over
diff --git a/app/javascript/flavours/glitch/actions/accounts.js b/app/javascript/flavours/glitch/actions/accounts.js
index 6b5b2ade5c..92442ff596 100644
--- a/app/javascript/flavours/glitch/actions/accounts.js
+++ b/app/javascript/flavours/glitch/actions/accounts.js
@@ -1,5 +1,5 @@
import api, { getLinks } from '../api';
-import { importAccount, importFetchedAccount, importFetchedAccounts } from './importer';
+import { importFetchedAccount, importFetchedAccounts } from './importer';
export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST';
export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS';
diff --git a/app/javascript/flavours/glitch/actions/timelines.js b/app/javascript/flavours/glitch/actions/timelines.js
index eb817daf9e..bde96c504b 100644
--- a/app/javascript/flavours/glitch/actions/timelines.js
+++ b/app/javascript/flavours/glitch/actions/timelines.js
@@ -3,7 +3,7 @@ import { submitMarkers } from './markers';
import api, { getLinks } from 'flavours/glitch/api';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import compareId from 'flavours/glitch/compare_id';
-import { me, usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state';
+import { usePendingItems as preferPendingItems } from 'flavours/glitch/initial_state';
import { toServerSideType } from 'flavours/glitch/utils/filters';
export const TIMELINE_UPDATE = 'TIMELINE_UPDATE';
@@ -121,7 +121,6 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) {
api(getState).get(path, { params }).then(response => {
const next = getLinks(response).refs.find(link => link.rel === 'next');
-
dispatch(importFetchedStatuses(response.data));
dispatch(expandTimelineSuccess(timelineId, response.data, next ? next.uri : null, response.status === 206, isLoadingRecent, isLoadingMore, isLoadingRecent && preferPendingItems));
@@ -163,10 +162,10 @@ export const expandListTimeline = (id, { maxId } = {}, done = noOp) =
export const expandHashtagTimeline = (hashtag, { maxId, tags, local } = {}, done = noOp) => {
return expandTimeline(`hashtag:${hashtag}${local ? ':local' : ''}`, `/api/v1/timelines/tag/${hashtag}`, {
max_id: maxId,
- any: parseTags(tags, 'any'),
- all: parseTags(tags, 'all'),
- none: parseTags(tags, 'none'),
- local: local,
+ any: parseTags(tags, 'any'),
+ all: parseTags(tags, 'all'),
+ none: parseTags(tags, 'none'),
+ local: local,
}, done);
};
diff --git a/app/javascript/flavours/glitch/components/avatar_composite.jsx b/app/javascript/flavours/glitch/components/avatar_composite.jsx
index c0ce7761dc..98ea9d2728 100644
--- a/app/javascript/flavours/glitch/components/avatar_composite.jsx
+++ b/app/javascript/flavours/glitch/components/avatar_composite.jsx
@@ -9,6 +9,7 @@ export default class AvatarComposite extends React.PureComponent {
accounts: ImmutablePropTypes.list.isRequired,
animate: PropTypes.bool,
size: PropTypes.number.isRequired,
+ onAccountClick: PropTypes.func.isRequired,
};
static defaultProps = {
diff --git a/app/javascript/flavours/glitch/components/display_name.jsx b/app/javascript/flavours/glitch/components/display_name.jsx
index 19f63ec60c..f58a8df824 100644
--- a/app/javascript/flavours/glitch/components/display_name.jsx
+++ b/app/javascript/flavours/glitch/components/display_name.jsx
@@ -14,6 +14,7 @@ export default class DisplayName extends React.PureComponent {
localDomain: PropTypes.string,
others: ImmutablePropTypes.list,
handleClick: PropTypes.func,
+ onAccountClick: PropTypes.func,
};
handleMouseEnter = ({ currentTarget }) => {
@@ -61,6 +62,7 @@ export default class DisplayName extends React.PureComponent {
if (others && others.size > 0) {
displayName = others.take(2).map(a => (
onAccountClick(a.get('acct'), e)}
diff --git a/app/javascript/flavours/glitch/components/icon_button.jsx b/app/javascript/flavours/glitch/components/icon_button.jsx
index 10d7926be5..93640dd0f2 100644
--- a/app/javascript/flavours/glitch/components/icon_button.jsx
+++ b/app/javascript/flavours/glitch/components/icon_button.jsx
@@ -1,6 +1,4 @@
import React from 'react';
-import Motion from '../features/ui/util/optional_motion';
-import spring from 'react-motion/lib/spring';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Icon from 'flavours/glitch/components/icon';
@@ -25,7 +23,7 @@ export default class IconButton extends React.PureComponent {
inverted: PropTypes.bool,
animate: PropTypes.bool,
overlay: PropTypes.bool,
- tabIndex: PropTypes.string,
+ tabIndex: PropTypes.number,
label: PropTypes.string,
counter: PropTypes.number,
obfuscateCount: PropTypes.bool,
@@ -39,7 +37,7 @@ export default class IconButton extends React.PureComponent {
disabled: false,
animate: false,
overlay: false,
- tabIndex: '0',
+ tabIndex: 0,
ariaHidden: false,
};
@@ -156,6 +154,7 @@ export default class IconButton extends React.PureComponent {
return (
diff --git a/app/javascript/flavours/glitch/features/notifications/components/admin_report.jsx b/app/javascript/flavours/glitch/features/notifications/components/admin_report.jsx
index 9b55fe4e98..436f64b5d2 100644
--- a/app/javascript/flavours/glitch/features/notifications/components/admin_report.jsx
+++ b/app/javascript/flavours/glitch/features/notifications/components/admin_report.jsx
@@ -2,22 +2,17 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
-import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
+import { FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { HotKeys } from 'react-hotkeys';
import classNames from 'classnames';
// Our imports.
import Permalink from 'flavours/glitch/components/permalink';
-import AccountContainer from 'flavours/glitch/containers/account_container';
import NotificationOverlayContainer from '../containers/overlay_container';
import Icon from 'flavours/glitch/components/icon';
import Report from './report';
-const messages = defineMessages({
- adminReport: { id: 'notification.admin.report', defaultMessage: '{name} reported {target}' },
-});
-
export default class AdminReport extends ImmutablePureComponent {
static propTypes = {
@@ -67,7 +62,7 @@ export default class AdminReport extends ImmutablePureComponent {
}
render () {
- const { intl, account, notification, unread, report } = this.props;
+ const { account, notification, unread, report } = this.props;
if (!report) {
return null;
diff --git a/app/javascript/flavours/glitch/features/notifications/containers/follow_request_container.js b/app/javascript/flavours/glitch/features/notifications/containers/follow_request_container.js
index 82357adfb0..004d1e173b 100644
--- a/app/javascript/flavours/glitch/features/notifications/containers/follow_request_container.js
+++ b/app/javascript/flavours/glitch/features/notifications/containers/follow_request_container.js
@@ -1,5 +1,4 @@
import { connect } from 'react-redux';
-import { makeGetAccount } from 'flavours/glitch/selectors';
import FollowRequest from '../components/follow_request';
import { authorizeFollowRequest, rejectFollowRequest } from 'flavours/glitch/actions/accounts';
diff --git a/app/javascript/flavours/glitch/features/notifications/index.jsx b/app/javascript/flavours/glitch/features/notifications/index.jsx
index 2de073077b..b9c9d82031 100644
--- a/app/javascript/flavours/glitch/features/notifications/index.jsx
+++ b/app/javascript/flavours/glitch/features/notifications/index.jsx
@@ -9,9 +9,9 @@ import {
enterNotificationClearingMode,
expandNotifications,
scrollTopNotifications,
+ loadPending,
mountNotifications,
unmountNotifications,
- loadPending,
markNotificationsAsRead,
} from 'flavours/glitch/actions/notifications';
import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/columns';
@@ -79,16 +79,6 @@ const mapDispatchToProps = dispatch => ({
onEnterCleaningMode(yes) {
dispatch(enterNotificationClearingMode(yes));
},
- onMarkAsRead() {
- dispatch(markNotificationsAsRead());
- dispatch(submitMarkers({ immediate: true }));
- },
- onMount() {
- dispatch(mountNotifications());
- },
- onUnmount() {
- dispatch(unmountNotifications());
- },
dispatch,
});
@@ -112,8 +102,6 @@ class Notifications extends React.PureComponent {
localSettings: ImmutablePropTypes.map,
notifCleaningActive: PropTypes.bool,
onEnterCleaningMode: PropTypes.func,
- onMount: PropTypes.func,
- onUnmount: PropTypes.func,
lastReadId: PropTypes.string,
canMarkAsRead: PropTypes.bool,
needsNotificationPermission: PropTypes.bool,
@@ -127,6 +115,18 @@ class Notifications extends React.PureComponent {
animatingNCD: false,
};
+ componentDidMount() {
+ this.props.dispatch(mountNotifications());
+ }
+
+ componentWillUnmount () {
+ this.handleLoadOlder.cancel();
+ this.handleScrollToTop.cancel();
+ this.handleScroll.cancel();
+ // this.props.dispatch(scrollTopNotifications(false));
+ this.props.dispatch(unmountNotifications());
+ }
+
handleLoadGap = (maxId) => {
this.props.dispatch(expandNotifications({ maxId }));
};
@@ -195,20 +195,6 @@ class Notifications extends React.PureComponent {
}
}
- componentDidMount () {
- const { onMount } = this.props;
- if (onMount) {
- onMount();
- }
- }
-
- componentWillUnmount () {
- const { onUnmount } = this.props;
- if (onUnmount) {
- onUnmount();
- }
- }
-
handleTransitionEndNCD = () => {
this.setState({ animatingNCD: false });
};
@@ -219,12 +205,13 @@ class Notifications extends React.PureComponent {
};
handleMarkAsRead = () => {
- this.props.onMarkAsRead();
+ this.props.dispatch(markNotificationsAsRead());
+ this.props.dispatch(submitMarkers({ immediate: true }));
};
render () {
const { intl, notifications, isLoading, isUnread, columnId, multiColumn, hasMore, numPending, showFilterBar, lastReadId, canMarkAsRead, needsNotificationPermission } = this.props;
- const { notifCleaning, notifCleaningActive } = this.props;
+ const { notifCleaningActive } = this.props;
const { animatingNCD } = this.state;
const pinned = !!columnId;
const emptyMessage = ;
diff --git a/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/account_container.js b/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/account_container.js
index 149d05c322..155afcca18 100644
--- a/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/account_container.js
+++ b/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/account_container.js
@@ -1,4 +1,3 @@
-import React from 'react';
import { connect } from 'react-redux';
import { makeGetAccount } from 'flavours/glitch/selectors';
import { injectIntl } from 'react-intl';
diff --git a/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/search_container.js b/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/search_container.js
index db586ecf71..0ada7b0401 100644
--- a/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/search_container.js
+++ b/app/javascript/flavours/glitch/features/pinned_accounts_editor/containers/search_container.js
@@ -1,4 +1,3 @@
-import React from 'react';
import { connect } from 'react-redux';
import { injectIntl } from 'react-intl';
import {
diff --git a/app/javascript/flavours/glitch/features/video/index.jsx b/app/javascript/flavours/glitch/features/video/index.jsx
index a73320e897..0a9db059eb 100644
--- a/app/javascript/flavours/glitch/features/video/index.jsx
+++ b/app/javascript/flavours/glitch/features/video/index.jsx
@@ -554,7 +554,7 @@ class Video extends React.PureComponent {
playerStyle.height = height;
} else if (inline) {
- return ();
+ return ();
}
let preload;