diff --git a/src/components/autosuggest-input.tsx b/src/components/autosuggest-input.tsx index 5a9b1bb84..be22bc92b 100644 --- a/src/components/autosuggest-input.tsx +++ b/src/components/autosuggest-input.tsx @@ -17,7 +17,7 @@ export type AutoSuggestion = string | Emoji; export interface IAutosuggestInput extends Pick, 'onChange' | 'onKeyUp' | 'onKeyDown'> { value: string; - suggestions: ImmutableList; + suggestions: any[]; disabled?: boolean; placeholder?: string; onSuggestionSelected: (tokenStart: number, lastToken: string | null, suggestion: AutoSuggestion) => void; @@ -81,7 +81,7 @@ export default class AutosuggestInput extends PureComponent { const { suggestions, menu, disabled } = this.props; const { selectedSuggestion, suggestionsHidden } = this.state; const firstIndex = this.getFirstIndex(); - const lastIndex = suggestions.size + (menu || []).length - 1; + const lastIndex = suggestions.length + (menu || []).length - 1; if (disabled) { e.preventDefault(); @@ -96,7 +96,7 @@ export default class AutosuggestInput extends PureComponent { switch (e.key) { case 'Escape': - if (suggestions.size === 0 || suggestionsHidden) { + if (suggestions.length === 0 || suggestionsHidden) { document.querySelector('.ui')?.parentElement?.focus(); } else { e.preventDefault(); @@ -105,14 +105,14 @@ export default class AutosuggestInput extends PureComponent { break; case 'ArrowDown': - if (!suggestionsHidden && (suggestions.size > 0 || menu)) { + if (!suggestionsHidden && (suggestions.length > 0 || menu)) { e.preventDefault(); this.setState({ selectedSuggestion: Math.min(selectedSuggestion + 1, lastIndex) }); } break; case 'ArrowUp': - if (!suggestionsHidden && (suggestions.size > 0 || menu)) { + if (!suggestionsHidden && (suggestions.length > 0 || menu)) { e.preventDefault(); this.setState({ selectedSuggestion: Math.max(selectedSuggestion - 1, firstIndex) }); } @@ -121,15 +121,15 @@ export default class AutosuggestInput extends PureComponent { case 'Enter': case 'Tab': // Select suggestion - if (!suggestionsHidden && selectedSuggestion > -1 && (suggestions.size > 0 || menu)) { + if (!suggestionsHidden && selectedSuggestion > -1 && (suggestions.length > 0 || menu)) { e.preventDefault(); e.stopPropagation(); this.setState({ selectedSuggestion: firstIndex }); - if (selectedSuggestion < suggestions.size) { - this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions.get(selectedSuggestion)); + if (selectedSuggestion < suggestions.length) { + this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestions[selectedSuggestion]); } else if (menu) { - const item = menu[selectedSuggestion - suggestions.size]; + const item = menu[selectedSuggestion - suggestions.length]; this.handleMenuItemAction(item, e); } } @@ -156,7 +156,7 @@ export default class AutosuggestInput extends PureComponent { onSuggestionClick: React.EventHandler = (e) => { const index = Number(e.currentTarget?.getAttribute('data-index')); - const suggestion = this.props.suggestions.get(index); + const suggestion = this.props.suggestions[index]; this.props.onSuggestionSelected(this.state.tokenStart, this.state.lastToken, suggestion); this.input?.focus(); e.preventDefault(); @@ -164,7 +164,7 @@ export default class AutosuggestInput extends PureComponent { componentDidUpdate(prevProps: IAutosuggestInput, prevState: any) { const { suggestions } = this.props; - if (suggestions !== prevProps.suggestions && suggestions.size > 0 && prevState.suggestionsHidden && prevState.focused) { + if (suggestions !== prevProps.suggestions && suggestions.length > 0 && prevState.suggestionsHidden && prevState.focused) { this.setState({ suggestionsHidden: false }); } } @@ -234,7 +234,7 @@ export default class AutosuggestInput extends PureComponent { return menu.map((item, i) => ( { const { value, suggestions, disabled, placeholder, onKeyUp, autoFocus, className, id, maxLength, menu, theme } = this.props; const { suggestionsHidden } = this.state; - const visible = !suggestionsHidden && (!suggestions.isEmpty() || (menu && value)); + const visible = !suggestionsHidden && (suggestions.length > 0 || (menu && value)); return [
diff --git a/src/components/modal-root.tsx b/src/components/modal-root.tsx index c2f077c65..31604f9e4 100644 --- a/src/components/modal-root.tsx +++ b/src/components/modal-root.tsx @@ -12,18 +12,18 @@ import { usePrevious } from 'soapbox/hooks/usePrevious.ts'; import type { ModalType } from 'soapbox/features/ui/components/modal-root.tsx'; import type { ReducerRecord as ReducerComposeEvent } from 'soapbox/reducers/compose-event.ts'; -import type { ReducerCompose } from 'soapbox/reducers/compose.ts'; +import type { Compose } from 'soapbox/reducers/compose.ts'; const messages = defineMessages({ confirm: { id: 'confirmations.cancel.confirm', defaultMessage: 'Discard' }, cancelEditing: { id: 'confirmations.cancel_editing.confirm', defaultMessage: 'Cancel editing' }, }); -export const checkComposeContent = (compose?: ReturnType) => { +export const checkComposeContent = (compose?: Compose) => { return !!compose && [ compose.editorState && compose.editorState.length > 0, compose.spoiler_text.length > 0, - compose.media_attachments.size > 0, + compose.media_attachments.length > 0, compose.poll !== null, ].some(check => check === true); }; @@ -69,7 +69,7 @@ const ModalRoot: React.FC = ({ children, onCancel, onClose, type }) const handleOnClose = () => { dispatch((_, getState) => { - const compose = getState().compose.get('compose-modal'); + const compose = getState().compose['compose-modal']; const hasComposeContent = checkComposeContent(compose); const hasEventComposeContent = checkEventComposeContent(getState().compose_event); diff --git a/src/features/compose/components/reply-group-indicator.tsx b/src/features/compose/components/reply-group-indicator.tsx index bc31ba585..ad61c6395 100644 --- a/src/features/compose/components/reply-group-indicator.tsx +++ b/src/features/compose/components/reply-group-indicator.tsx @@ -16,7 +16,7 @@ const ReplyGroupIndicator = (props: IReplyGroupIndicator) => { const getStatus = useCallback(makeGetStatus(), []); - const status = useAppSelector((state) => getStatus(state, { id: state.compose.get(composeId)?.in_reply_to! })); + const status = useAppSelector((state) => getStatus(state, { id: state.compose[composeId]?.in_reply_to! })); const group = status?.group as Group; if (!group) { diff --git a/src/features/compose/components/reply-mentions.tsx b/src/features/compose/components/reply-mentions.tsx index 8c3cbeb3d..e99df7138 100644 --- a/src/features/compose/components/reply-mentions.tsx +++ b/src/features/compose/components/reply-mentions.tsx @@ -59,14 +59,14 @@ const ReplyMentions: React.FC = ({ composeId }) => { ); } - const accounts = to.slice(0, 2).map((acct: string) => { + const accounts = [...to].slice(0, 2).map((acct: string) => { const username = acct.split('@')[0]; return ( {/* eslint-disable-line formatjs/no-literal-string-in-jsx */} @{shortenNostr(username)} ); - }).toArray(); + }); if (to.size > 2) { accounts.push(