From b57687083f4af178f2e2f43665eb4e49d32a50c2 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 5 Mar 2025 17:55:53 +0100 Subject: [PATCH] Move `app/javascript/hooks` to `app/javascript/mastodon/hooks` (#34077) --- app/javascript/entrypoints/embed.tsx | 2 +- app/javascript/mastodon/components/account_bio.tsx | 2 +- app/javascript/mastodon/components/account_fields.tsx | 2 +- app/javascript/mastodon/components/alt_text_badge.tsx | 2 +- app/javascript/mastodon/components/avatar.tsx | 2 +- app/javascript/mastodon/components/avatar_overlay.tsx | 5 ++--- app/javascript/mastodon/components/copy_paste_text.tsx | 2 +- app/javascript/mastodon/components/gif.tsx | 2 +- app/javascript/mastodon/components/hover_card_controller.tsx | 2 +- .../features/account_timeline/components/account_header.tsx | 2 +- .../features/alt_text_modal/components/info_button.tsx | 2 +- app/javascript/mastodon/features/directory/index.tsx | 3 +-- app/javascript/mastodon/features/search/index.tsx | 2 +- app/javascript/mastodon/features/standalone/status/index.tsx | 2 +- app/javascript/{ => mastodon}/hooks/useHovering.ts | 0 app/javascript/{ => mastodon}/hooks/useLinks.ts | 0 app/javascript/{ => mastodon}/hooks/useRenderSignal.ts | 0 app/javascript/{ => mastodon}/hooks/useSearchParam.ts | 0 app/javascript/{ => mastodon}/hooks/useSelectableClick.ts | 0 app/javascript/{ => mastodon}/hooks/useTimeout.ts | 0 20 files changed, 15 insertions(+), 17 deletions(-) rename app/javascript/{ => mastodon}/hooks/useHovering.ts (100%) rename app/javascript/{ => mastodon}/hooks/useLinks.ts (100%) rename app/javascript/{ => mastodon}/hooks/useRenderSignal.ts (100%) rename app/javascript/{ => mastodon}/hooks/useSearchParam.ts (100%) rename app/javascript/{ => mastodon}/hooks/useSelectableClick.ts (100%) rename app/javascript/{ => mastodon}/hooks/useTimeout.ts (100%) diff --git a/app/javascript/entrypoints/embed.tsx b/app/javascript/entrypoints/embed.tsx index cb62727563..6c091e4d07 100644 --- a/app/javascript/entrypoints/embed.tsx +++ b/app/javascript/entrypoints/embed.tsx @@ -1,7 +1,7 @@ import './public-path'; import { createRoot } from 'react-dom/client'; -import { afterInitialRender } from 'mastodon/../hooks/useRenderSignal'; +import { afterInitialRender } from 'mastodon/hooks/useRenderSignal'; import { start } from '../mastodon/common'; import { Status } from '../mastodon/features/standalone/status'; diff --git a/app/javascript/mastodon/components/account_bio.tsx b/app/javascript/mastodon/components/account_bio.tsx index 9d523c7402..301ffcbb24 100644 --- a/app/javascript/mastodon/components/account_bio.tsx +++ b/app/javascript/mastodon/components/account_bio.tsx @@ -1,4 +1,4 @@ -import { useLinks } from 'mastodon/../hooks/useLinks'; +import { useLinks } from 'mastodon/hooks/useLinks'; export const AccountBio: React.FC<{ note: string; diff --git a/app/javascript/mastodon/components/account_fields.tsx b/app/javascript/mastodon/components/account_fields.tsx index e297f99e3a..4ce55f7896 100644 --- a/app/javascript/mastodon/components/account_fields.tsx +++ b/app/javascript/mastodon/components/account_fields.tsx @@ -1,8 +1,8 @@ import classNames from 'classnames'; import CheckIcon from '@/material-icons/400-24px/check.svg?react'; -import { useLinks } from 'mastodon/../hooks/useLinks'; import { Icon } from 'mastodon/components/icon'; +import { useLinks } from 'mastodon/hooks/useLinks'; import type { Account } from 'mastodon/models/account'; export const AccountFields: React.FC<{ diff --git a/app/javascript/mastodon/components/alt_text_badge.tsx b/app/javascript/mastodon/components/alt_text_badge.tsx index 466c5cf1bc..701cfbe8b4 100644 --- a/app/javascript/mastodon/components/alt_text_badge.tsx +++ b/app/javascript/mastodon/components/alt_text_badge.tsx @@ -8,7 +8,7 @@ import type { UsePopperOptions, } from 'react-overlays/esm/usePopper'; -import { useSelectableClick } from '@/hooks/useSelectableClick'; +import { useSelectableClick } from 'mastodon/hooks/useSelectableClick'; const offset = [0, 4] as OffsetValue; const popperConfig = { strategy: 'fixed' } as UsePopperOptions; diff --git a/app/javascript/mastodon/components/avatar.tsx b/app/javascript/mastodon/components/avatar.tsx index f61d9676de..a2dc0b782e 100644 --- a/app/javascript/mastodon/components/avatar.tsx +++ b/app/javascript/mastodon/components/avatar.tsx @@ -2,7 +2,7 @@ import { useState, useCallback } from 'react'; import classNames from 'classnames'; -import { useHovering } from 'mastodon/../hooks/useHovering'; +import { useHovering } from 'mastodon/hooks/useHovering'; import { autoPlayGif } from 'mastodon/initial_state'; import type { Account } from 'mastodon/models/account'; diff --git a/app/javascript/mastodon/components/avatar_overlay.tsx b/app/javascript/mastodon/components/avatar_overlay.tsx index f98cfcc38b..0bd33fea69 100644 --- a/app/javascript/mastodon/components/avatar_overlay.tsx +++ b/app/javascript/mastodon/components/avatar_overlay.tsx @@ -1,8 +1,7 @@ +import { useHovering } from 'mastodon/hooks/useHovering'; +import { autoPlayGif } from 'mastodon/initial_state'; import type { Account } from 'mastodon/models/account'; -import { useHovering } from '../../hooks/useHovering'; -import { autoPlayGif } from '../initial_state'; - interface Props { account: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there friend: Account | undefined; // FIXME: remove `undefined` once we know for sure its always there diff --git a/app/javascript/mastodon/components/copy_paste_text.tsx b/app/javascript/mastodon/components/copy_paste_text.tsx index f888acd0f7..e6eba765ab 100644 --- a/app/javascript/mastodon/components/copy_paste_text.tsx +++ b/app/javascript/mastodon/components/copy_paste_text.tsx @@ -5,8 +5,8 @@ import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import ContentCopyIcon from '@/material-icons/400-24px/content_copy.svg?react'; -import { useTimeout } from 'mastodon/../hooks/useTimeout'; import { Icon } from 'mastodon/components/icon'; +import { useTimeout } from 'mastodon/hooks/useTimeout'; export const CopyPasteText: React.FC<{ value: string }> = ({ value }) => { const inputRef = useRef(null); diff --git a/app/javascript/mastodon/components/gif.tsx b/app/javascript/mastodon/components/gif.tsx index 8fbcb8c76b..1cc0881a5a 100644 --- a/app/javascript/mastodon/components/gif.tsx +++ b/app/javascript/mastodon/components/gif.tsx @@ -1,4 +1,4 @@ -import { useHovering } from '@/hooks/useHovering'; +import { useHovering } from 'mastodon/hooks/useHovering'; import { autoPlayGif } from 'mastodon/initial_state'; export const GIF: React.FC<{ diff --git a/app/javascript/mastodon/components/hover_card_controller.tsx b/app/javascript/mastodon/components/hover_card_controller.tsx index 057ef1aaed..38c3306f30 100644 --- a/app/javascript/mastodon/components/hover_card_controller.tsx +++ b/app/javascript/mastodon/components/hover_card_controller.tsx @@ -8,8 +8,8 @@ import type { UsePopperOptions, } from 'react-overlays/esm/usePopper'; -import { useTimeout } from 'mastodon/../hooks/useTimeout'; import { HoverCardAccount } from 'mastodon/components/hover_card_account'; +import { useTimeout } from 'mastodon/hooks/useTimeout'; const offset = [-12, 4] as OffsetValue; const enterDelay = 750; diff --git a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx index f9c01eba6b..e48558d019 100644 --- a/app/javascript/mastodon/features/account_timeline/components/account_header.tsx +++ b/app/javascript/mastodon/features/account_timeline/components/account_header.tsx @@ -6,7 +6,6 @@ import classNames from 'classnames'; import { Helmet } from 'react-helmet'; import { NavLink } from 'react-router-dom'; -import { useLinks } from '@/hooks/useLinks'; import CheckIcon from '@/material-icons/400-24px/check.svg?react'; import LockIcon from '@/material-icons/400-24px/lock.svg?react'; import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; @@ -46,6 +45,7 @@ import DropdownMenuContainer from 'mastodon/containers/dropdown_menu_container'; import { DomainPill } from 'mastodon/features/account/components/domain_pill'; import AccountNoteContainer from 'mastodon/features/account/containers/account_note_container'; import FollowRequestNoteContainer from 'mastodon/features/account/containers/follow_request_note_container'; +import { useLinks } from 'mastodon/hooks/useLinks'; import { useIdentity } from 'mastodon/identity_context'; import { autoPlayGif, me, domain as localDomain } from 'mastodon/initial_state'; import type { Account } from 'mastodon/models/account'; diff --git a/app/javascript/mastodon/features/alt_text_modal/components/info_button.tsx b/app/javascript/mastodon/features/alt_text_modal/components/info_button.tsx index f867dfb393..aecf9cbc2f 100644 --- a/app/javascript/mastodon/features/alt_text_modal/components/info_button.tsx +++ b/app/javascript/mastodon/features/alt_text_modal/components/info_button.tsx @@ -6,9 +6,9 @@ import classNames from 'classnames'; import Overlay from 'react-overlays/Overlay'; -import { useSelectableClick } from '@/hooks/useSelectableClick'; import QuestionMarkIcon from '@/material-icons/400-24px/question_mark.svg?react'; import { Icon } from 'mastodon/components/icon'; +import { useSelectableClick } from 'mastodon/hooks/useSelectableClick'; const messages = defineMessages({ help: { id: 'info_button.label', defaultMessage: 'Help' }, diff --git a/app/javascript/mastodon/features/directory/index.tsx b/app/javascript/mastodon/features/directory/index.tsx index ef2649a27f..1374f99235 100644 --- a/app/javascript/mastodon/features/directory/index.tsx +++ b/app/javascript/mastodon/features/directory/index.tsx @@ -22,10 +22,9 @@ import { LoadMore } from 'mastodon/components/load_more'; import { LoadingIndicator } from 'mastodon/components/loading_indicator'; import { RadioButton } from 'mastodon/components/radio_button'; import ScrollContainer from 'mastodon/containers/scroll_container'; +import { useSearchParam } from 'mastodon/hooks/useSearchParam'; import { useAppDispatch, useAppSelector } from 'mastodon/store'; -import { useSearchParam } from '../../../hooks/useSearchParam'; - import { AccountCard } from './components/account_card'; const messages = defineMessages({ diff --git a/app/javascript/mastodon/features/search/index.tsx b/app/javascript/mastodon/features/search/index.tsx index 1f0e759b96..f85fba1f78 100644 --- a/app/javascript/mastodon/features/search/index.tsx +++ b/app/javascript/mastodon/features/search/index.tsx @@ -4,7 +4,6 @@ import { useIntl, defineMessages, FormattedMessage } from 'react-intl'; import { Helmet } from 'react-helmet'; -import { useSearchParam } from '@/hooks/useSearchParam'; import FindInPageIcon from '@/material-icons/400-24px/find_in_page.svg?react'; import PeopleIcon from '@/material-icons/400-24px/group.svg?react'; import SearchIcon from '@/material-icons/400-24px/search.svg?react'; @@ -20,6 +19,7 @@ import { Icon } from 'mastodon/components/icon'; import ScrollableList from 'mastodon/components/scrollable_list'; import Status from 'mastodon/containers/status_container'; import { Search } from 'mastodon/features/compose/components/search'; +import { useSearchParam } from 'mastodon/hooks/useSearchParam'; import type { Hashtag as HashtagType } from 'mastodon/models/tags'; import { useAppDispatch, useAppSelector } from 'mastodon/store'; diff --git a/app/javascript/mastodon/features/standalone/status/index.tsx b/app/javascript/mastodon/features/standalone/status/index.tsx index 3b68c5c176..8d1b831467 100644 --- a/app/javascript/mastodon/features/standalone/status/index.tsx +++ b/app/javascript/mastodon/features/standalone/status/index.tsx @@ -6,11 +6,11 @@ import { useEffect, useCallback } from 'react'; import { Provider } from 'react-redux'; -import { useRenderSignal } from 'mastodon/../hooks/useRenderSignal'; import { fetchStatus, toggleStatusSpoilers } from 'mastodon/actions/statuses'; import { hydrateStore } from 'mastodon/actions/store'; import { Router } from 'mastodon/components/router'; import { DetailedStatus } from 'mastodon/features/status/components/detailed_status'; +import { useRenderSignal } from 'mastodon/hooks/useRenderSignal'; import initialState from 'mastodon/initial_state'; import { IntlProvider } from 'mastodon/locales'; import { makeGetStatus, makeGetPictureInPicture } from 'mastodon/selectors'; diff --git a/app/javascript/hooks/useHovering.ts b/app/javascript/mastodon/hooks/useHovering.ts similarity index 100% rename from app/javascript/hooks/useHovering.ts rename to app/javascript/mastodon/hooks/useHovering.ts diff --git a/app/javascript/hooks/useLinks.ts b/app/javascript/mastodon/hooks/useLinks.ts similarity index 100% rename from app/javascript/hooks/useLinks.ts rename to app/javascript/mastodon/hooks/useLinks.ts diff --git a/app/javascript/hooks/useRenderSignal.ts b/app/javascript/mastodon/hooks/useRenderSignal.ts similarity index 100% rename from app/javascript/hooks/useRenderSignal.ts rename to app/javascript/mastodon/hooks/useRenderSignal.ts diff --git a/app/javascript/hooks/useSearchParam.ts b/app/javascript/mastodon/hooks/useSearchParam.ts similarity index 100% rename from app/javascript/hooks/useSearchParam.ts rename to app/javascript/mastodon/hooks/useSearchParam.ts diff --git a/app/javascript/hooks/useSelectableClick.ts b/app/javascript/mastodon/hooks/useSelectableClick.ts similarity index 100% rename from app/javascript/hooks/useSelectableClick.ts rename to app/javascript/mastodon/hooks/useSelectableClick.ts diff --git a/app/javascript/hooks/useTimeout.ts b/app/javascript/mastodon/hooks/useTimeout.ts similarity index 100% rename from app/javascript/hooks/useTimeout.ts rename to app/javascript/mastodon/hooks/useTimeout.ts