From 2fe75db85c19f3bcdfdbb639de3d36fa02f56c76 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Mon, 24 Nov 2025 04:44:46 -0800 Subject: [PATCH] Linter catching a bunch of stuff that needed fixing --- app/javascript/mastodon/actions/lists.js | 128 ------------------ .../mastodon/actions/notification_groups.ts | 4 - .../mastodon/components/account/index.tsx | 4 +- .../mastodon/components/hashtag.tsx | 2 +- .../mastodon/components/no_alt_text_badge.tsx | 4 +- .../mastodon/features/audio/index.tsx | 30 +++- .../directory/components/account_card.tsx | 7 +- .../status/components/detailed_status.tsx | 6 +- .../mastodon/features/video/index.tsx | 30 +++- .../mastodon/reducers/notification_groups.ts | 1 - 10 files changed, 65 insertions(+), 151 deletions(-) diff --git a/app/javascript/mastodon/actions/lists.js b/app/javascript/mastodon/actions/lists.js index 1cee938db..a4bbfff22 100644 --- a/app/javascript/mastodon/actions/lists.js +++ b/app/javascript/mastodon/actions/lists.js @@ -4,23 +4,6 @@ export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST'; export const LIST_FETCH_SUCCESS = 'LIST_FETCH_SUCCESS'; export const LIST_FETCH_FAIL = 'LIST_FETCH_FAIL'; -export const LISTS_FETCH_REQUEST = 'LISTS_FETCH_REQUEST'; -export const LISTS_FETCH_SUCCESS = 'LISTS_FETCH_SUCCESS'; -export const LISTS_FETCH_FAIL = 'LISTS_FETCH_FAIL'; - -export const LIST_EDITOR_TITLE_CHANGE = 'LIST_EDITOR_TITLE_CHANGE'; -export const LIST_EDITOR_IS_EXCLUSIVE_CHANGE = 'LIST_EDITOR_IS_EXCLUSIVE_CHANGE'; -export const LIST_EDITOR_RESET = 'LIST_EDITOR_RESET'; -export const LIST_EDITOR_SETUP = 'LIST_EDITOR_SETUP'; - -export const LIST_CREATE_REQUEST = 'LIST_CREATE_REQUEST'; -export const LIST_CREATE_SUCCESS = 'LIST_CREATE_SUCCESS'; -export const LIST_CREATE_FAIL = 'LIST_CREATE_FAIL'; - -export const LIST_UPDATE_REQUEST = 'LIST_UPDATE_REQUEST'; -export const LIST_UPDATE_SUCCESS = 'LIST_UPDATE_SUCCESS'; -export const LIST_UPDATE_FAIL = 'LIST_UPDATE_FAIL'; - export const LIST_DELETE_REQUEST = 'LIST_DELETE_REQUEST'; export const LIST_DELETE_SUCCESS = 'LIST_DELETE_SUCCESS'; export const LIST_DELETE_FAIL = 'LIST_DELETE_FAIL'; @@ -55,117 +38,6 @@ export const fetchListFail = (id, error) => ({ error, }); -export const fetchLists = () => (dispatch) => { - dispatch(fetchListsRequest()); - - api().get('/api/v1/lists') - .then(({ data }) => dispatch(fetchListsSuccess(data))) - .catch(err => dispatch(fetchListsFail(err))); -}; - -export const fetchListsRequest = () => ({ - type: LISTS_FETCH_REQUEST, -}); - -export const fetchListsSuccess = lists => ({ - type: LISTS_FETCH_SUCCESS, - lists, -}); - -export const fetchListsFail = error => ({ - type: LISTS_FETCH_FAIL, - error, -}); - -export const submitListEditor = shouldReset => (dispatch, getState) => { - const listId = getState().getIn(['listEditor', 'listId']); - const title = getState().getIn(['listEditor', 'title']); - const isExclusive = getState().getIn(['listEditor', 'isExclusive']); - - if (listId === null) { - dispatch(createList(title, shouldReset)); - } else { - dispatch(updateList(listId, title, shouldReset, isExclusive)); - } -}; - -export const setupListEditor = listId => (dispatch, getState) => { - dispatch({ - type: LIST_EDITOR_SETUP, - list: getState().getIn(['lists', listId]), - }); - - dispatch(fetchListAccounts(listId)); -}; - -export const changeListEditorTitle = value => ({ - type: LIST_EDITOR_TITLE_CHANGE, - value, -}); - -export const changeListEditorIsExclusive = value => ({ - type: LIST_EDITOR_IS_EXCLUSIVE_CHANGE, - value, -}); - -export const createList = (title, shouldReset) => (dispatch) => { - dispatch(createListRequest()); - - api().post('/api/v1/lists', { title }).then(({ data }) => { - dispatch(createListSuccess(data)); - - if (shouldReset) { - dispatch(resetListEditor()); - } - }).catch(err => dispatch(createListFail(err))); -}; - -export const createListRequest = () => ({ - type: LIST_CREATE_REQUEST, -}); - -export const createListSuccess = list => ({ - type: LIST_CREATE_SUCCESS, - list, -}); - -export const createListFail = error => ({ - type: LIST_CREATE_FAIL, - error, -}); - -export const updateList = (id, title, shouldReset, isExclusive, replies_policy) => (dispatch) => { - dispatch(updateListRequest(id)); - - api().put(`/api/v1/lists/${id}`, { title, replies_policy, exclusive: typeof isExclusive === 'undefined' ? undefined : !!isExclusive }).then(({ data }) => { - dispatch(updateListSuccess(data)); - - if (shouldReset) { - dispatch(resetListEditor()); - } - }).catch(err => dispatch(updateListFail(id, err))); -}; - -export const updateListRequest = id => ({ - type: LIST_UPDATE_REQUEST, - id, -}); - -export const updateListSuccess = list => ({ - type: LIST_UPDATE_SUCCESS, - list, -}); - -export const updateListFail = (id, error) => ({ - type: LIST_UPDATE_FAIL, - id, - error, -}); - -export const resetListEditor = () => ({ - type: LIST_EDITOR_RESET, -}); - export const deleteList = id => (dispatch) => { dispatch(deleteListRequest(id)); diff --git a/app/javascript/mastodon/actions/notification_groups.ts b/app/javascript/mastodon/actions/notification_groups.ts index ffd144ddc..438632548 100644 --- a/app/javascript/mastodon/actions/notification_groups.ts +++ b/app/javascript/mastodon/actions/notification_groups.ts @@ -78,10 +78,6 @@ function selectNotificationGroupedTypes(state: RootState) { return types; } -export function shouldGroupNotificationType(type: string) { - return supportedGroupedNotificationTypes.includes(type); -} - export const fetchNotifications = createDataLoadingThunk( 'notificationGroups/fetch', async (_params, { getState }) => diff --git a/app/javascript/mastodon/components/account/index.tsx b/app/javascript/mastodon/components/account/index.tsx index ade17012d..5c0716412 100644 --- a/app/javascript/mastodon/components/account/index.tsx +++ b/app/javascript/mastodon/components/account/index.tsx @@ -3,7 +3,6 @@ import { useCallback, useMemo } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; import classNames from 'classnames'; -import { Permalink } from 'react-router-dom'; import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; import { @@ -25,6 +24,7 @@ import { FollowersCounter } from 'mastodon/components/counters'; import { DisplayName } from 'mastodon/components/display_name'; import { Dropdown } from 'mastodon/components/dropdown_menu'; import { FollowButton } from 'mastodon/components/follow_button'; +import { Permalink } from 'mastodon/components/permalink'; import { RelativeTimestamp } from 'mastodon/components/relative_timestamp'; import { ShortNumber } from 'mastodon/components/short_number'; import { Skeleton } from 'mastodon/components/skeleton'; @@ -296,7 +296,7 @@ export const Account: React.FC = ({ diff --git a/app/javascript/mastodon/components/hashtag.tsx b/app/javascript/mastodon/components/hashtag.tsx index 45ffce1e9..346c95183 100644 --- a/app/javascript/mastodon/components/hashtag.tsx +++ b/app/javascript/mastodon/components/hashtag.tsx @@ -4,12 +4,12 @@ import { Component } from 'react'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; +import { Link } from 'react-router-dom'; import type Immutable from 'immutable'; import { Sparklines, SparklinesCurve } from 'react-sparklines'; -import { Link } from 'react-router-dom'; import { ShortNumber } from 'mastodon/components/short_number'; import { Skeleton } from 'mastodon/components/skeleton'; import type { Hashtag as HashtagType } from 'mastodon/models/tags'; diff --git a/app/javascript/mastodon/components/no_alt_text_badge.tsx b/app/javascript/mastodon/components/no_alt_text_badge.tsx index 2c80cac2c..136855cd3 100644 --- a/app/javascript/mastodon/components/no_alt_text_badge.tsx +++ b/app/javascript/mastodon/components/no_alt_text_badge.tsx @@ -8,13 +8,13 @@ import type { UsePopperOptions, } from 'react-overlays/esm/usePopper'; -import { Icon } from 'mastodon/components/icon'; import WarningIcon from '@/material-icons/400-24px/warning.svg?react'; +import { Icon } from 'mastodon/components/icon'; const offset = [0, 4] as OffsetValue; const popperConfig = { strategy: 'fixed' } as UsePopperOptions; -export const NoAltTextBadge: React.FC<{}> = () => { +export const NoAltTextBadge: React.FC = () => { const anchorRef = useRef(null); const [open, setOpen] = useState(false); diff --git a/app/javascript/mastodon/features/audio/index.tsx b/app/javascript/mastodon/features/audio/index.tsx index 1a0f43103..980603bf5 100644 --- a/app/javascript/mastodon/features/audio/index.tsx +++ b/app/javascript/mastodon/features/audio/index.tsx @@ -13,11 +13,11 @@ import PlayArrowIcon from '@/material-icons/400-24px/play_arrow-fill.svg?react'; import Replay5Icon from '@/material-icons/400-24px/replay_5-fill.svg?react'; import VolumeOffIcon from '@/material-icons/400-24px/volume_off-fill.svg?react'; import VolumeUpIcon from '@/material-icons/400-24px/volume_up-fill.svg?react'; +import { AltTextBadge } from 'mastodon/components/alt_text_badge'; import { Blurhash } from 'mastodon/components/blurhash'; import { Icon } from 'mastodon/components/icon'; -import { SpoilerButton } from 'mastodon/components/spoiler_button'; -import { AltTextBadge } from 'mastodon/components/alt_text_badge'; import { NoAltTextBadge } from 'mastodon/components/no_alt_text_badge'; +import { SpoilerButton } from 'mastodon/components/spoiler_button'; import { formatTime, getPointerPosition } from 'mastodon/features/video'; import { useAudioContext } from 'mastodon/hooks/useAudioContext'; import { useAudioVisualizer } from 'mastodon/hooks/useAudioVisualizer'; @@ -33,6 +33,10 @@ const messages = defineMessages({ hide: { id: 'audio.hide', defaultMessage: 'Hide audio' }, skipForward: { id: 'video.skip_forward', defaultMessage: 'Skip forward' }, skipBackward: { id: 'video.skip_backward', defaultMessage: 'Skip backward' }, + no_descriptive_text: { + id: 'media.no_descriptive_text', + defaultMessage: 'No descriptive text was provided for this media.', + }, }); const persistVolume = (volume: number, muted: boolean) => { @@ -810,8 +814,26 @@ export const Audio: React.FC<{
- {alt && } - {!alt && } + {alt && ( + + )} + {!alt && ( + + )} {!editable && ( <> } - {!alt && } + {alt && ( + + )} + {!alt && ( + + )} {!fullscreen && onOpenVideo && (