cleanup JS imports and other minor stuff

This commit is contained in:
fef 2022-12-01 23:30:39 +01:00 committed by neatchee
parent 2b43aba58c
commit eab49f22c0
13 changed files with 15 additions and 47 deletions

View file

@ -429,14 +429,12 @@ export const addReactionRequest = (statusId, name) => ({
type: REACTION_ADD_REQUEST,
id: statusId,
name,
skipLoading: true,
});
export const addReactionSuccess = (statusId, name) => ({
type: REACTION_ADD_SUCCESS,
id: statusId,
name,
skipLoading: true,
});
export const addReactionFail = (statusId, name, error) => ({
@ -444,7 +442,6 @@ export const addReactionFail = (statusId, name, error) => ({
id: statusId,
name,
error,
skipLoading: true,
});
export const removeReaction = (statusId, name) => (dispatch, getState) => {
@ -461,19 +458,16 @@ export const removeReactionRequest = (statusId, name) => ({
type: REACTION_REMOVE_REQUEST,
id: statusId,
name,
skipLoading: true,
});
export const removeReactionSuccess = (statusId, name) => ({
type: REACTION_REMOVE_SUCCESS,
id: statusId,
name,
skipLoading: true,
});
export const removeReactionFail = (statusId, name) => ({
type: REACTION_REMOVE_FAIL,
id: statusId,
name,
skipLoading: true,
});

View file

@ -1,7 +1,7 @@
import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { reduceMotion } from '../initial_state';
import { autoPlayGif, reduceMotion } from '../initial_state';
import spring from 'react-motion/lib/spring';
import TransitionMotion from 'react-motion/lib/TransitionMotion';
import classNames from 'classnames';
@ -9,7 +9,6 @@ import React from 'react';
import unicodeMapping from '../features/emoji/emoji_unicode_mapping_light';
import AnimatedNumber from './animated_number';
import { assetHost } from '../utils/config';
import { autoPlayGif } from '../initial_state';
export default class StatusReactions extends ImmutablePureComponent {
@ -101,19 +100,12 @@ class Reaction extends ImmutablePureComponent {
render() {
const { reaction } = this.props;
let shortCode = reaction.get('name');
if (unicodeMapping[shortCode]) {
shortCode = unicodeMapping[shortCode].shortCode;
}
return (
<button
className={classNames('reactions-bar__item', { active: reaction.get('me') })}
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
title={`:${shortCode}:`}
style={this.props.style}
>
<span className='reactions-bar__item__emoji'>

View file

@ -29,7 +29,6 @@ const messages = defineMessages({
rewrite_mentions_username: { id: 'settings.rewrite_mentions_username', defaultMessage: 'Rewrite with username' },
pop_in_left: { id: 'settings.pop_in_left', defaultMessage: 'Left' },
pop_in_right: { id: 'settings.pop_in_right', defaultMessage: 'Right' },
enter_amount_prompt: { id: 'settings.enter_amount_prompt', defaultMessage: 'Enter an amount' },
});
class LocalSettingsPage extends React.PureComponent {

View file

@ -22,21 +22,20 @@ export default class LocalSettingsPageItem extends React.PureComponent {
})),
settings: ImmutablePropTypes.map.isRequired,
placeholder: PropTypes.string,
number: PropTypes.bool,
disabled: PropTypes.bool,
};
handleChange = e => {
const { target } = e;
const { item, onChange, options, placeholder, number } = this.props;
const { item, onChange, options, placeholder } = this.props;
if (options && options.length > 0) onChange(item, target.value);
else if (placeholder) onChange(item, number ? parseInt(target.value) : target.value);
else if (placeholder) onChange(item, target.value);
else onChange(item, target.checked);
};
render () {
const { handleChange } = this;
const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, number, disabled } = this.props;
const { settings, item, id, inputProps, options, children, dependsOn, dependsOnNot, placeholder, disabled } = this.props;
let enabled = !disabled;
if (dependsOn) {
@ -81,7 +80,7 @@ export default class LocalSettingsPageItem extends React.PureComponent {
</fieldset>
</div>
);
} else if (placeholder || number) {
} else if (placeholder) {
return (
<div className='glitch local-settings__page__item string'>
<label htmlFor={id}>
@ -89,7 +88,7 @@ export default class LocalSettingsPageItem extends React.PureComponent {
<p>
<input
id={id}
type={number ? 'number' : 'text'}
type='text'
value={settings.getIn(item)}
placeholder={placeholder}
onChange={handleChange}

View file

@ -20,7 +20,7 @@ import Icon from 'flavours/glitch/components/icon';
import AnimatedNumber from 'flavours/glitch/components/animated_number';
import PictureInPicturePlaceholder from 'flavours/glitch/components/picture_in_picture_placeholder';
import EditedTimestamp from 'flavours/glitch/components/edited_timestamp';
import StatusReactions from '../../../components/status_reactions';
import StatusReactions from 'flavours/glitch/components/status_reactions';
class DetailedStatus extends ImmutablePureComponent {

View file

@ -43,7 +43,7 @@ import { initMuteModal } from 'flavours/glitch/actions/mutes';
import { initBlockModal } from 'flavours/glitch/actions/blocks';
import { initReport } from 'flavours/glitch/actions/reports';
import { initBoostModal } from 'flavours/glitch/actions/boosts';
import { makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors';
import { makeCustomEmojiMap, makeGetStatus, makeGetPictureInPicture } from 'flavours/glitch/selectors';
import ScrollContainer from 'flavours/glitch/containers/scroll_container';
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
import ColumnHeader from '../../components/column_header';
@ -58,7 +58,6 @@ import { autoUnfoldCW } from 'flavours/glitch/utils/content_warning';
import { textForScreenReader, defaultMediaVisibility } from 'flavours/glitch/components/status';
import Icon from 'flavours/glitch/components/icon';
import { Helmet } from 'react-helmet';
import { makeCustomEmojiMap } from '../../selectors';
const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },

View file

@ -61,6 +61,7 @@
* @property {boolean} limited_federation_mode
* @property {string} locale
* @property {string | null} mascot
* @property {number} max_reactions
* @property {string=} me
* @property {string=} moved_to_account_id
* @property {string=} owner
@ -80,6 +81,7 @@
* @property {boolean} use_blurhash
* @property {boolean=} use_pending_items
* @property {string} version
* @property {number} visible_reactions
* @property {boolean} translation_enabled
* @property {object} local_settings
*/
@ -125,7 +127,6 @@ export const mascot = getMeta('mascot');
export const maxReactions = (initialState && initialState.max_reactions) || 1;
export const me = getMeta('me');
export const movedToAccountId = getMeta('moved_to_account_id');
export const visibleReactions = getMeta('visible_reactions');
export const owner = getMeta('owner');
export const profile_directory = getMeta('profile_directory');
export const reduceMotion = getMeta('reduce_motion');

View file

@ -449,14 +449,12 @@ export const addReactionRequest = (statusId, name) => ({
type: REACTION_ADD_REQUEST,
id: statusId,
name,
skipLoading: true,
});
export const addReactionSuccess = (statusId, name) => ({
type: REACTION_ADD_SUCCESS,
id: statusId,
name,
skipLoading: true,
});
export const addReactionFail = (statusId, name, error) => ({
@ -464,7 +462,6 @@ export const addReactionFail = (statusId, name, error) => ({
id: statusId,
name,
error,
skipLoading: true,
});
export const removeReaction = (statusId, name) => (dispatch, getState) => {
@ -481,19 +478,16 @@ export const removeReactionRequest = (statusId, name) => ({
type: REACTION_REMOVE_REQUEST,
id: statusId,
name,
skipLoading: true,
});
export const removeReactionSuccess = (statusId, name) => ({
type: REACTION_REMOVE_SUCCESS,
id: statusId,
name,
skipLoading: true,
});
export const removeReactionFail = (statusId, name) => ({
type: REACTION_REMOVE_FAIL,
id: statusId,
name,
skipLoading: true,
});

View file

@ -16,13 +16,12 @@ import { MediaGallery, Video, Audio } from '../features/ui/util/async-components
import { HotKeys } from 'react-hotkeys';
import classNames from 'classnames';
import Icon from 'mastodon/components/icon';
import { displayMedia } from '../initial_state';
import { displayMedia, visibleReactions } from '../initial_state';
import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder';
// We use the component (and not the container) since we do not want
// to use the progress bar to show download progress
import Bundle from '../features/ui/components/bundle';
import { visibleReactions } from '../initial_state';
export const textForScreenReader = (intl, status, rebloggedByText = false) => {
const displayName = status.getIn(['account', 'display_name']);

View file

@ -1,7 +1,7 @@
import ImmutablePureComponent from 'react-immutable-pure-component';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { reduceMotion } from '../initial_state';
import { autoPlayGif, reduceMotion } from '../initial_state';
import spring from 'react-motion/lib/spring';
import TransitionMotion from 'react-motion/lib/TransitionMotion';
import classNames from 'classnames';
@ -9,7 +9,6 @@ import React from 'react';
import unicodeMapping from '../features/emoji/emoji_unicode_mapping_light';
import AnimatedNumber from './animated_number';
import { assetHost } from '../utils/config';
import { autoPlayGif } from '../initial_state';
export default class StatusReactions extends ImmutablePureComponent {
@ -101,19 +100,12 @@ class Reaction extends ImmutablePureComponent {
render() {
const { reaction } = this.props;
let shortCode = reaction.get('name');
if (unicodeMapping[shortCode]) {
shortCode = unicodeMapping[shortCode].shortCode;
}
return (
<button
className={classNames('reactions-bar__item', { active: reaction.get('me') })}
onClick={this.handleClick}
onMouseEnter={this.handleMouseEnter}
onMouseLeave={this.handleMouseLeave}
title={`:${shortCode}:`}
style={this.props.style}
>
<span className='reactions-bar__item__emoji'>

View file

@ -17,7 +17,7 @@ import Icon from 'mastodon/components/icon';
import AnimatedNumber from 'mastodon/components/animated_number';
import PictureInPicturePlaceholder from 'mastodon/components/picture_in_picture_placeholder';
import EditedTimestamp from 'mastodon/components/edited_timestamp';
import StatusReactions from '../../../components/status_reactions';
import StatusReactions from 'mastodon/components/status_reactions';
const messages = defineMessages({
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },

View file

@ -50,7 +50,7 @@ import { initMuteModal } from '../../actions/mutes';
import { initBlockModal } from '../../actions/blocks';
import { initBoostModal } from '../../actions/boosts';
import { initReport } from '../../actions/reports';
import { makeGetStatus, makeGetPictureInPicture } from '../../selectors';
import { makeCustomEmojiMap, makeGetStatus, makeGetPictureInPicture } from '../../selectors';
import ScrollContainer from 'mastodon/containers/scroll_container';
import ColumnBackButton from '../../components/column_back_button';
import ColumnHeader from '../../components/column_header';
@ -64,7 +64,6 @@ import { attachFullscreenListener, detachFullscreenListener, isFullscreen } from
import { textForScreenReader, defaultMediaVisibility } from '../../components/status';
import Icon from 'mastodon/components/icon';
import { Helmet } from 'react-helmet';
import { makeCustomEmojiMap } from '../../selectors';
const messages = defineMessages({
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },

View file

@ -61,6 +61,7 @@
* @property {boolean} limited_federation_mode
* @property {string} locale
* @property {string | null} mascot
* @property {number} max_reactions
* @property {string=} me
* @property {string=} moved_to_account_id
* @property {string=} owner
@ -116,7 +117,6 @@ export const mascot = getMeta('mascot');
export const maxReactions = (initialState && initialState.max_reactions) || 1;
export const me = getMeta('me');
export const movedToAccountId = getMeta('moved_to_account_id');
export const visibleReactions = getMeta('visible_reactions');
export const owner = getMeta('owner');
export const profile_directory = getMeta('profile_directory');
export const reduceMotion = getMeta('reduce_motion');