From 241faae836c829801d4928ea02f7a569d0fc379c Mon Sep 17 00:00:00 2001 From: diondiondion Date: Thu, 25 Jun 2026 09:54:30 +0200 Subject: [PATCH] [Glitch] Remove dependency resolution override for React 19 types Port f2e10fd5db285ad4e8c5f9d44b226384a304e167 to glitch-soc Co-authored-by: ChaosExAnima Signed-off-by: Claire --- .../glitch/components/account_header/fields.tsx | 4 ++-- .../glitch/components/account_header/name.tsx | 2 +- .../account_header/subscription_form.tsx | 2 +- .../glitch/components/alt_text_badge/index.tsx | 2 +- .../glitch/components/carousel/index.tsx | 4 ++-- .../glitch/components/dropdown/index.tsx | 2 +- .../flavours/glitch/components/dropdown_menu.tsx | 4 ++-- .../components/form_fields/checkbox_field.tsx | 2 +- .../components/form_fields/combobox_field.tsx | 4 ++-- .../components/form_fields/copy_link_field.tsx | 2 +- .../components/form_fields/emoji_text_field.tsx | 2 +- .../flavours/glitch/components/hotkeys/index.tsx | 2 +- .../glitch/components/hover_card_controller.tsx | 2 +- .../glitch/components/learn_more_link.tsx | 4 ++-- .../components/navigation_focus_target/index.tsx | 5 +++-- .../status_action_bar/remove_quote_hint.tsx | 4 ++-- .../glitch/containers/scroll_container/index.tsx | 11 ++++++++--- .../components/featured_tags.tsx | 2 +- .../account_timeline/components/filters.tsx | 4 ++-- .../alt_text_modal/components/info_button.tsx | 2 +- .../glitch/features/alt_text_modal/index.tsx | 2 +- .../flavours/glitch/features/audio/index.tsx | 4 ++-- .../glitch/features/collections/detail/index.tsx | 2 +- .../features/collections/editor/accounts.tsx | 5 +++-- .../features/collections/editor/details.tsx | 5 +++-- .../compose/components/language_dropdown.tsx | 6 +++--- .../compose/components/privacy_dropdown.tsx | 6 +++--- .../glitch/features/emoji/emoji_picker.tsx | 11 ++++++----- .../glitch/features/interaction_modal/index.tsx | 2 +- .../glitch/features/navigation_panel/index.tsx | 4 ++-- .../components/select_with_label.tsx | 2 +- .../components/embedded_status.tsx | 2 +- .../notification_severed_relationships.tsx | 1 + .../glitch/features/onboarding/follows.tsx | 2 +- .../status/components/detailed_status.tsx | 2 +- .../features/ui/components/columns_area.tsx | 5 ++++- .../features/ui/components/embed_modal.tsx | 2 +- .../features/ui/components/zoomable_image.tsx | 4 ++-- .../flavours/glitch/features/video/index.tsx | 6 +++--- .../flavours/glitch/hooks/useAudioContext.ts | 8 ++++---- .../flavours/glitch/hooks/useAudioVisualizer.ts | 6 +++--- .../flavours/glitch/hooks/useObserver.ts | 4 ++-- .../flavours/glitch/hooks/useOnClickOutside.ts | 4 ++-- .../flavours/glitch/hooks/useOverflow.ts | 16 +++++++--------- .../flavours/glitch/hooks/useSearchAccounts.ts | 2 +- .../flavours/glitch/hooks/useSearchTags.ts | 2 +- .../flavours/glitch/hooks/useSelectableClick.ts | 2 +- .../flavours/glitch/hooks/useTimeout.ts | 8 ++++---- app/javascript/flavours/glitch/utils/html.ts | 4 ++-- 49 files changed, 103 insertions(+), 92 deletions(-) diff --git a/app/javascript/flavours/glitch/components/account_header/fields.tsx b/app/javascript/flavours/glitch/components/account_header/fields.tsx index ab441ba71c..22aba72670 100644 --- a/app/javascript/flavours/glitch/components/account_header/fields.tsx +++ b/app/javascript/flavours/glitch/components/account_header/fields.tsx @@ -220,7 +220,7 @@ const FieldHTML: FC = ({ }; function useColumnWrap() { - const listRef = useRef(null); + const listRef = useRef(null); const handleRecalculate = useCallback(() => { const listEle = listRef.current; @@ -330,7 +330,7 @@ function useFieldOverflow() { const [isLabelOverflowing, setIsLabelOverflowing] = useState(false); const [isValueOverflowing, setIsValueOverflowing] = useState(false); - const wrapperRef = useRef(null); + const wrapperRef = useRef(null); const handleRecalculate = useCallback(() => { const wrapperEle = wrapperRef.current; diff --git a/app/javascript/flavours/glitch/components/account_header/name.tsx b/app/javascript/flavours/glitch/components/account_header/name.tsx index aca296c311..7dd12813c0 100644 --- a/app/javascript/flavours/glitch/components/account_header/name.tsx +++ b/app/javascript/flavours/glitch/components/account_header/name.tsx @@ -111,7 +111,7 @@ const AccountNameHelp: FC<{ } onHide={handleClick} offset={[5, 5]} > diff --git a/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx b/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx index 1f27d8a3d1..04ada5d0f4 100644 --- a/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx +++ b/app/javascript/flavours/glitch/components/account_header/subscription_form.tsx @@ -90,7 +90,7 @@ export const AccountSubscriptionForm: React.FC<{ accountId: string }> = ({ [], ); - const handleSubmit = useCallback( + const handleSubmit = useCallback( (e) => { e.preventDefault(); diff --git a/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx b/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx index a6f55af770..7321063e1a 100644 --- a/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx +++ b/app/javascript/flavours/glitch/components/alt_text_badge/index.tsx @@ -64,7 +64,7 @@ export const AltTextBadge: React.FC<{ rootClose onHide={handleClose} show={open} - target={buttonRef} + target={buttonRef as React.RefObject} placement='top-end' flip offset={offset} diff --git a/app/javascript/flavours/glitch/components/carousel/index.tsx b/app/javascript/flavours/glitch/components/carousel/index.tsx index bc287aa969..391e7fa7c5 100644 --- a/app/javascript/flavours/glitch/components/carousel/index.tsx +++ b/app/javascript/flavours/glitch/components/carousel/index.tsx @@ -106,7 +106,7 @@ export const Carousel = < [items.length, onChangeSlide], ); - const observerRef = useRef(null); + const observerRef = useRef(null); observerRef.current ??= new ResizeObserver(() => { handleSlideChange(0); }); @@ -235,7 +235,7 @@ const CarouselSlideWrapper = ({ className={className} role='group' aria-roledescription='slide' - inert={active ? undefined : ''} + inert={active} data-index={index} > {children} diff --git a/app/javascript/flavours/glitch/components/dropdown/index.tsx b/app/javascript/flavours/glitch/components/dropdown/index.tsx index 4edc78f50b..eec14bdc52 100644 --- a/app/javascript/flavours/glitch/components/dropdown/index.tsx +++ b/app/javascript/flavours/glitch/components/dropdown/index.tsx @@ -109,7 +109,7 @@ export const Dropdown: FC< placement='bottom-start' onHide={handleClose} flip - target={buttonRef} + target={buttonRef as React.RefObject} popperConfig={{ strategy: 'fixed', modifiers: [matchWidth], diff --git a/app/javascript/flavours/glitch/components/dropdown_menu.tsx b/app/javascript/flavours/glitch/components/dropdown_menu.tsx index 2982c839d0..7e08156598 100644 --- a/app/javascript/flavours/glitch/components/dropdown_menu.tsx +++ b/app/javascript/flavours/glitch/components/dropdown_menu.tsx @@ -352,7 +352,7 @@ export const Dropdown = ({ ); const [currentId] = useState(id++); const open = currentId === openDropdownId; - const buttonRef = useRef(null); + const buttonRef = useRef(null); const menuId = useId(); const prefetchAccountId = status ? status.getIn(['account', 'id']) @@ -518,7 +518,7 @@ export const Dropdown = ({ offset={offset} placement={placement} flip - target={buttonRef} + target={buttonRef as React.RefObject} popperConfig={popperConfig} > {({ props, arrowProps, placement }) => ( diff --git a/app/javascript/flavours/glitch/components/form_fields/checkbox_field.tsx b/app/javascript/flavours/glitch/components/form_fields/checkbox_field.tsx index c08b81ca36..78bbb32e4f 100644 --- a/app/javascript/flavours/glitch/components/form_fields/checkbox_field.tsx +++ b/app/javascript/flavours/glitch/components/form_fields/checkbox_field.tsx @@ -30,7 +30,7 @@ CheckboxField.displayName = 'CheckboxField'; export const Checkbox = forwardRef( ({ className, size, indeterminate, ...otherProps }, ref) => { - const inputRef = useRef(null); + const inputRef = useRef(null); const handleRef = useCallback( (element: HTMLInputElement | null) => { diff --git a/app/javascript/flavours/glitch/components/form_fields/combobox_field.tsx b/app/javascript/flavours/glitch/components/form_fields/combobox_field.tsx index a1d66c30a9..8cae26ca6a 100644 --- a/app/javascript/flavours/glitch/components/form_fields/combobox_field.tsx +++ b/app/javascript/flavours/glitch/components/form_fields/combobox_field.tsx @@ -236,7 +236,7 @@ const ComboboxWithRef = ( ) => { const intl = useIntl(); const wrapperRef = useRef(null); - const inputRef = useRef(); + const inputRef = useRef(null); const popoverRef = useRef(null); // This ref tracks whether the menu was just closed following a @@ -558,7 +558,7 @@ const ComboboxWithRef = ( onHide={closeMenu} ref={popoverRef} target={inputRef as React.RefObject} - container={wrapperRef} + container={wrapperRef as React.RefObject} popperConfig={{ modifiers: [matchWidth], }} diff --git a/app/javascript/flavours/glitch/components/form_fields/copy_link_field.tsx b/app/javascript/flavours/glitch/components/form_fields/copy_link_field.tsx index aa2b63392d..2d12cd9eed 100644 --- a/app/javascript/flavours/glitch/components/form_fields/copy_link_field.tsx +++ b/app/javascript/flavours/glitch/components/form_fields/copy_link_field.tsx @@ -26,7 +26,7 @@ export const CopyLinkField = forwardRef( ref, ) => { const intl = useIntl(); - const inputRef = useRef(); + const inputRef = useRef(null); const handleFocus = useCallback(() => { inputRef.current?.select(); }, []); diff --git a/app/javascript/flavours/glitch/components/form_fields/emoji_text_field.tsx b/app/javascript/flavours/glitch/components/form_fields/emoji_text_field.tsx index 7e0b45abb4..26ffcfb4a0 100644 --- a/app/javascript/flavours/glitch/components/form_fields/emoji_text_field.tsx +++ b/app/javascript/flavours/glitch/components/form_fields/emoji_text_field.tsx @@ -120,7 +120,7 @@ const EmojiFieldWrapper: FC< children: ( inputProps: InputProps & { onChange: ChangeEventHandler }, ) => ReactNode; - inputRef: RefObject; + inputRef: RefObject; } > = ({ value, diff --git a/app/javascript/flavours/glitch/components/hotkeys/index.tsx b/app/javascript/flavours/glitch/components/hotkeys/index.tsx index 8d511b68e3..a725c0cc95 100644 --- a/app/javascript/flavours/glitch/components/hotkeys/index.tsx +++ b/app/javascript/flavours/glitch/components/hotkeys/index.tsx @@ -185,7 +185,7 @@ export type HandlerMap = Partial>; export function useHotkeys(handlers: HandlerMap) { const ref = useRef(null); const bufferedKeys = useRef([]); - const sequenceTimer = useRef | null>(null); + const sequenceTimer = useRef>(null); /** * Store the latest handlers object in a ref so we don't need to diff --git a/app/javascript/flavours/glitch/components/hover_card_controller.tsx b/app/javascript/flavours/glitch/components/hover_card_controller.tsx index 37ad0d4c93..b392fdb982 100644 --- a/app/javascript/flavours/glitch/components/hover_card_controller.tsx +++ b/app/javascript/flavours/glitch/components/hover_card_controller.tsx @@ -27,7 +27,7 @@ export const HoverCardController: React.FC = () => { const [open, setOpen] = useState(false); const [accountId, setAccountId] = useState(); const [anchor, setAnchor] = useState(null); - const cardRef = useRef(null); + const cardRef = useRef(null); const [setLeaveTimeout, cancelLeaveTimeout] = useTimeout(); const [setEnterTimeout, cancelEnterTimeout, delayEnterTimeout] = useTimeout(); const [setScrollTimeout] = useTimeout(); diff --git a/app/javascript/flavours/glitch/components/learn_more_link.tsx b/app/javascript/flavours/glitch/components/learn_more_link.tsx index 8d22bb7a3b..a721ad2747 100644 --- a/app/javascript/flavours/glitch/components/learn_more_link.tsx +++ b/app/javascript/flavours/glitch/components/learn_more_link.tsx @@ -9,7 +9,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({ }) => { const accessibilityId = useId(); const [open, setOpen] = useState(false); - const triggerRef = useRef(null); + const triggerRef = useRef(null); const handleClick = useCallback(() => { setOpen(!open); @@ -37,7 +37,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({ onHide={handleClick} offset={[5, 5]} placement='bottom-end' - target={triggerRef} + target={triggerRef as React.RefObject} > {({ props }) => (
| null>(null); +const FocusTargetContext = createContext | null>( + null, +); /** * `FocusTargetProvider` keeps track of whether focus should be diff --git a/app/javascript/flavours/glitch/components/status_action_bar/remove_quote_hint.tsx b/app/javascript/flavours/glitch/components/status_action_bar/remove_quote_hint.tsx index ab76ed6407..ccb260d805 100644 --- a/app/javascript/flavours/glitch/components/status_action_bar/remove_quote_hint.tsx +++ b/app/javascript/flavours/glitch/components/status_action_bar/remove_quote_hint.tsx @@ -65,8 +65,8 @@ export const RemoveQuoteHint: React.FC<{ flip offset={[12, 10]} placement='bottom-end' - target={anchorRef} - container={anchorRef} + target={anchorRef as React.RefObject} + container={anchorRef as React.RefObject} > {({ props, placement }) => (
= ({ }) => { const scrollBehaviorContext = useContext(ScrollBehaviorContext); - const containerRef = useRef(); + const containerRef = useRef(null); /** * If a childRef is passed, sync it with the containerRef. This * is necessary because in this component's return statement, * we're overwriting the immediate child component's ref prop. */ - useImperativeHandle(childRef, () => containerRef.current, []); + useImperativeHandle(childRef, () => containerRef.current ?? undefined, []); /** * Register/unregister scrollable element with ScrollBehavior @@ -71,6 +72,10 @@ export const ScrollContainer: React.FC = ({ }, []); return React.Children.only( - React.cloneElement(children, { ref: containerRef }), + isValidElement<{ + ref: React.RefObject; + }>(children) + ? React.cloneElement(children, { ref: containerRef }) + : children, ); }; diff --git a/app/javascript/flavours/glitch/features/account_timeline/components/featured_tags.tsx b/app/javascript/flavours/glitch/features/account_timeline/components/featured_tags.tsx index 8534e45215..6378e3d569 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/components/featured_tags.tsx +++ b/app/javascript/flavours/glitch/features/account_timeline/components/featured_tags.tsx @@ -56,7 +56,7 @@ export const FeaturedTags: FC<{ accountId: string }> = ({ accountId }) => { 0 && index >= hiddenIndex ? '' : undefined} + inert={hiddenIndex > 0 && index >= hiddenIndex} onClick={onClick} active={currentTag === name} data-name={name} diff --git a/app/javascript/flavours/glitch/features/account_timeline/components/filters.tsx b/app/javascript/flavours/glitch/features/account_timeline/components/filters.tsx index c0f84fee59..c3e6c269c4 100644 --- a/app/javascript/flavours/glitch/features/account_timeline/components/filters.tsx +++ b/app/javascript/flavours/glitch/features/account_timeline/components/filters.tsx @@ -99,11 +99,11 @@ const FilterDropdown: FC = () => { } placement='bottom-start' rootClose onHide={handleHide} - container={containerRef} + container={containerRef as React.RefObject} > {({ props }) => (
{ placement='top' onHide={handleClick} offset={[5, 5]} - target={triggerRef} + target={triggerRef as React.RefObject} > {({ props }) => (
void; }> = ({ mediaId, position, onPositionChange }) => { - const nodeRef = useRef(null); + const nodeRef = useRef(null); const [dragging, setDragging] = useState<'started' | 'moving' | null>(null); diff --git a/app/javascript/flavours/glitch/features/audio/index.tsx b/app/javascript/flavours/glitch/features/audio/index.tsx index 0a1a054bdd..c07c6df20f 100644 --- a/app/javascript/flavours/glitch/features/audio/index.tsx +++ b/app/javascript/flavours/glitch/features/audio/index.tsx @@ -114,10 +114,10 @@ export const Audio: React.FC<{ const [revealed, setRevealed] = useState(false); const playerRef = useRef(null); - const audioRef = useRef(null); + const audioRef = useRef(null); const seekRef = useRef(null); const volumeRef = useRef(null); - const hoverTimeoutRef = useRef | null>(); + const hoverTimeoutRef = useRef>(null); const { audioContextRef, sourceRef, gainNodeRef, playAudio, pauseAudio } = useAudioContext({ audioElementRef: audioRef }); diff --git a/app/javascript/flavours/glitch/features/collections/detail/index.tsx b/app/javascript/flavours/glitch/features/collections/detail/index.tsx index 7bafb765fa..753a108e2c 100644 --- a/app/javascript/flavours/glitch/features/collections/detail/index.tsx +++ b/app/javascript/flavours/glitch/features/collections/detail/index.tsx @@ -170,7 +170,7 @@ const SensitiveContentNote: React.FC<{ onReveal: () => void }> = ({ const CollectionHeader: React.FC<{ collection: ApiCollectionJSON; withDescription: boolean; - headingRef: React.RefObject; + headingRef: React.RefObject; }> = ({ collection, withDescription, headingRef }) => { const intl = useIntl(); const { name, description, tag, account_id, items } = collection; diff --git a/app/javascript/flavours/glitch/features/collections/editor/accounts.tsx b/app/javascript/flavours/glitch/features/collections/editor/accounts.tsx index 78ac4951b7..82f43c8f03 100644 --- a/app/javascript/flavours/glitch/features/collections/editor/accounts.tsx +++ b/app/javascript/flavours/glitch/features/collections/editor/accounts.tsx @@ -1,3 +1,4 @@ +import type React from 'react'; import { useCallback, useId, useMemo, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; @@ -342,8 +343,8 @@ export const CollectionAccounts: React.FC<{ [addAccountItem, instantAddAccountItem, isEditMode, resetAccounts], ); - const handleSubmit = useCallback( - (e: React.FormEvent) => { + const handleSubmit: React.SubmitEventHandler = useCallback( + (e) => { e.preventDefault(); if (!id) { diff --git a/app/javascript/flavours/glitch/features/collections/editor/details.tsx b/app/javascript/flavours/glitch/features/collections/editor/details.tsx index 954ab0842d..be0db44f93 100644 --- a/app/javascript/flavours/glitch/features/collections/editor/details.tsx +++ b/app/javascript/flavours/glitch/features/collections/editor/details.tsx @@ -1,3 +1,4 @@ +import type React from 'react'; import { useCallback, useMemo } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; @@ -108,8 +109,8 @@ export const CollectionDetails: React.FC = () => { const accountId = useCurrentAccountId(); const { acct: currentUserName } = useAccount(accountId) ?? {}; - const handleSubmit = useCallback( - (e: React.FormEvent) => { + const handleSubmit: React.SubmitEventHandler = useCallback( + (e) => { e.preventDefault(); if (id) { diff --git a/app/javascript/flavours/glitch/features/compose/components/language_dropdown.tsx b/app/javascript/flavours/glitch/features/compose/components/language_dropdown.tsx index 07885c8c1b..7a3c799705 100644 --- a/app/javascript/flavours/glitch/features/compose/components/language_dropdown.tsx +++ b/app/javascript/flavours/glitch/features/compose/components/language_dropdown.tsx @@ -328,8 +328,8 @@ export const LanguageDropdown: React.FC = () => { const [open, setOpen] = useState(false); const [placement, setPlacement] = useState('bottom'); const [guess, setGuess] = useState(''); - const activeElementRef = useRef(null); - const targetRef = useRef(null); + const activeElementRef = useRef(null); + const targetRef = useRef(null); const intl = useIntl(); @@ -421,7 +421,7 @@ export const LanguageDropdown: React.FC = () => { offset={[5, 5]} placement={placement} flip - target={targetRef} + target={targetRef as React.RefObject} popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }} > {({ props, placement }) => ( diff --git a/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.tsx b/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.tsx index ae15d01dce..0a2d267eb5 100644 --- a/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.tsx +++ b/app/javascript/flavours/glitch/features/compose/components/privacy_dropdown.tsx @@ -70,8 +70,8 @@ const PrivacyDropdown: React.FC = ({ disabled, }) => { const intl = useIntl(); - const overlayTargetRef = useRef(null); - const previousFocusTargetRef = useRef(null); + const overlayTargetRef = useRef(null); + const previousFocusTargetRef = useRef(null); const [isOpen, setIsOpen] = useState(false); const handleClose = useCallback(() => { @@ -171,7 +171,7 @@ const PrivacyDropdown: React.FC = ({ offset={[5, 5]} placement='bottom' flip - target={overlayTargetRef} + target={overlayTargetRef as React.RefObject} container={container} popperConfig={{ strategy: 'fixed' }} > diff --git a/app/javascript/flavours/glitch/features/emoji/emoji_picker.tsx b/app/javascript/flavours/glitch/features/emoji/emoji_picker.tsx index 5a8ddb7ff1..e5f0763d31 100644 --- a/app/javascript/flavours/glitch/features/emoji/emoji_picker.tsx +++ b/app/javascript/flavours/glitch/features/emoji/emoji_picker.tsx @@ -51,15 +51,16 @@ export const Emoji: FC = ({ const { mode } = useEmojiAppState(); return ( ); diff --git a/app/javascript/flavours/glitch/features/interaction_modal/index.tsx b/app/javascript/flavours/glitch/features/interaction_modal/index.tsx index 4154c53f18..8342914458 100644 --- a/app/javascript/flavours/glitch/features/interaction_modal/index.tsx +++ b/app/javascript/flavours/glitch/features/interaction_modal/index.tsx @@ -153,7 +153,7 @@ const LoginForm: React.FC<{ const inputRef = useRef(null); const iframeRef = useRef(null); - const searchRequestRef = useRef(null); + const searchRequestRef = useRef(null); useEffect(() => { const handleMessage = (event: MessageEvent) => { diff --git a/app/javascript/flavours/glitch/features/navigation_panel/index.tsx b/app/javascript/flavours/glitch/features/navigation_panel/index.tsx index a3d36ad6e4..7edebbc260 100644 --- a/app/javascript/flavours/glitch/features/navigation_panel/index.tsx +++ b/app/javascript/flavours/glitch/features/navigation_panel/index.tsx @@ -465,7 +465,7 @@ export const CollapsibleNavigationPanel: React.FC = () => { const dispatch = useAppDispatch(); const openable = useBreakpoint('openable'); const location = useLocation(); - const overlayRef = useRef(null); + const overlayRef = useRef(null); useEffect(() => { dispatch(closeNavigation()); @@ -551,7 +551,7 @@ export const CollapsibleNavigationPanel: React.FC = () => { }, ); - const previouslyFocusedElementRef = useRef(); + const previouslyFocusedElementRef = useRef(null); useEffect(() => { if (open) { diff --git a/app/javascript/flavours/glitch/features/notifications/components/select_with_label.tsx b/app/javascript/flavours/glitch/features/notifications/components/select_with_label.tsx index d75fe82ba1..a7ea6241df 100644 --- a/app/javascript/flavours/glitch/features/notifications/components/select_with_label.tsx +++ b/app/javascript/flavours/glitch/features/notifications/components/select_with_label.tsx @@ -86,7 +86,7 @@ const Dropdown: React.FC = ({ offset={[5, 5]} placement={placement} flip - target={containerRef} + target={containerRef as React.RefObject} popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }} > {({ props, placement }) => ( diff --git a/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status.tsx b/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status.tsx index bd47b3dcac..71005206cc 100644 --- a/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status.tsx +++ b/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status.tsx @@ -26,7 +26,7 @@ export const EmbeddedStatus: React.FC<{ statusId: string }> = ({ statusId, }) => { const history = useHistory(); - const clickCoordinatesRef = useRef<[number, number] | null>(); + const clickCoordinatesRef = useRef<[number, number]>(null); const dispatch = useAppDispatch(); const status = useAppSelector((state) => state.statuses.get(statusId)); diff --git a/app/javascript/flavours/glitch/features/notifications_v2/components/notification_severed_relationships.tsx b/app/javascript/flavours/glitch/features/notifications_v2/components/notification_severed_relationships.tsx index 9c2b0b3edb..fff3dcad0f 100644 --- a/app/javascript/flavours/glitch/features/notifications_v2/components/notification_severed_relationships.tsx +++ b/app/javascript/flavours/glitch/features/notifications_v2/components/notification_severed_relationships.tsx @@ -11,5 +11,6 @@ export const NotificationSeveredRelationships: React.FC<{ followersCount={event.followers_count} followingCount={event.following_count} unread={unread} + hidden={false} /> ); diff --git a/app/javascript/flavours/glitch/features/onboarding/follows.tsx b/app/javascript/flavours/glitch/features/onboarding/follows.tsx index e8ab620929..825f4658dc 100644 --- a/app/javascript/flavours/glitch/features/onboarding/follows.tsx +++ b/app/javascript/flavours/glitch/features/onboarding/follows.tsx @@ -61,7 +61,7 @@ export const Follows: React.FC<{ setIsSearching(false); }, [setMode, setIsSearching]); - const searchRequestRef = useRef(null); + const searchRequestRef = useRef(null); const handleSearch = useDebouncedCallback( (value: string) => { diff --git a/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx b/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx index 8a20ea81b3..ab1c83e895 100644 --- a/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx +++ b/app/javascript/flavours/glitch/features/status/components/detailed_status.tsx @@ -84,7 +84,7 @@ export const DetailedStatus: React.FC<{ const properStatus = status?.get('reblog') ?? status; const [height, setHeight] = useState(0); const [showDespiteFilter, setShowDespiteFilter] = useState(false); - const nodeRef = useRef(); + const nodeRef = useRef(null); const letterboxMedia = useAppSelector( (state) => diff --git a/app/javascript/flavours/glitch/features/ui/components/columns_area.tsx b/app/javascript/flavours/glitch/features/ui/components/columns_area.tsx index 3cccf8f7e0..a71ae19e65 100644 --- a/app/javascript/flavours/glitch/features/ui/components/columns_area.tsx +++ b/app/javascript/flavours/glitch/features/ui/components/columns_area.tsx @@ -3,6 +3,7 @@ import { cloneElement, createContext, forwardRef, + isValidElement, useCallback, useContext, } from 'react'; @@ -179,7 +180,9 @@ export const ColumnsArea = forwardRef< {Children.map(children, (child) => - cloneElement(child, { multiColumn: true }), + isValidElement<{ multiColumn?: boolean }>(child) + ? cloneElement(child, { multiColumn: true }) + : child, )} diff --git a/app/javascript/flavours/glitch/features/ui/components/embed_modal.tsx b/app/javascript/flavours/glitch/features/ui/components/embed_modal.tsx index 01f683901a..a31437a81d 100644 --- a/app/javascript/flavours/glitch/features/ui/components/embed_modal.tsx +++ b/app/javascript/flavours/glitch/features/ui/components/embed_modal.tsx @@ -18,7 +18,7 @@ const EmbedModal: React.FC<{ onClose: () => void; }> = ({ id, onClose }) => { const iframeRef = useRef(null); - const intervalRef = useRef>(); + const intervalRef = useRef>(null); const [oembed, setOembed] = useState(null); const dispatch = useAppDispatch(); diff --git a/app/javascript/flavours/glitch/features/ui/components/zoomable_image.tsx b/app/javascript/flavours/glitch/features/ui/components/zoomable_image.tsx index beb2ee40d0..e5d20ee601 100644 --- a/app/javascript/flavours/glitch/features/ui/components/zoomable_image.tsx +++ b/app/javascript/flavours/glitch/features/ui/components/zoomable_image.tsx @@ -120,8 +120,8 @@ export const ZoomableImage: React.FC = ({ const containerRef = useRef(null); const imageRef = useRef(null); - const doubleClickTimeoutRef = useRef | null>(); - const zoomMatrixRef = useRef(null); + const doubleClickTimeoutRef = useRef>(null); + const zoomMatrixRef = useRef(null); const [style, api] = useSpring(() => ({ x: 0, diff --git a/app/javascript/flavours/glitch/features/video/index.tsx b/app/javascript/flavours/glitch/features/video/index.tsx index b43bfae703..248ddb83c3 100644 --- a/app/javascript/flavours/glitch/features/video/index.tsx +++ b/app/javascript/flavours/glitch/features/video/index.tsx @@ -229,11 +229,11 @@ export const Video: React.FC<{ const [hotkeyEvents, setHotkeyEvents] = useState([]); const playerRef = useRef(null); - const videoRef = useRef(null); + const videoRef = useRef(null); const seekRef = useRef(null); const volumeRef = useRef(null); - const doubleClickTimeoutRef = useRef | null>(); - const hoverTimeoutRef = useRef | null>(); + const doubleClickTimeoutRef = useRef>(null); + const hoverTimeoutRef = useRef>(null); const [style, api] = useSpring(() => ({ progress: '0%', diff --git a/app/javascript/flavours/glitch/hooks/useAudioContext.ts b/app/javascript/flavours/glitch/hooks/useAudioContext.ts index 2cad7ee3a5..65b20ff101 100644 --- a/app/javascript/flavours/glitch/hooks/useAudioContext.ts +++ b/app/javascript/flavours/glitch/hooks/useAudioContext.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef } from 'react'; interface AudioContextOptions { - audioElementRef: React.MutableRefObject; + audioElementRef: React.RefObject; } /** @@ -13,9 +13,9 @@ interface AudioContextOptions { */ export const useAudioContext = ({ audioElementRef }: AudioContextOptions) => { - const audioContextRef = useRef(); - const sourceRef = useRef(); - const gainNodeRef = useRef(); + const audioContextRef = useRef(null); + const sourceRef = useRef(null); + const gainNodeRef = useRef(null); useEffect(() => { if (!audioElementRef.current || typeof AudioContext === 'undefined') { diff --git a/app/javascript/flavours/glitch/hooks/useAudioVisualizer.ts b/app/javascript/flavours/glitch/hooks/useAudioVisualizer.ts index efc0647d8d..fefb1a2c4d 100644 --- a/app/javascript/flavours/glitch/hooks/useAudioVisualizer.ts +++ b/app/javascript/flavours/glitch/hooks/useAudioVisualizer.ts @@ -11,8 +11,8 @@ const normalizeFrequencies = (arr: Float32Array): number[] => { }; interface AudioVisualiserOptions { - audioContextRef: React.MutableRefObject; - sourceRef: React.MutableRefObject; + audioContextRef: React.RefObject; + sourceRef: React.RefObject; numBands: number; } @@ -21,7 +21,7 @@ export const useAudioVisualizer = ({ sourceRef, numBands, }: AudioVisualiserOptions) => { - const analyzerRef = useRef(); + const analyzerRef = useRef(null); const [frequencyBands, setFrequencyBands] = useState( new Array(numBands).fill(0), diff --git a/app/javascript/flavours/glitch/hooks/useObserver.ts b/app/javascript/flavours/glitch/hooks/useObserver.ts index 4b979f6d32..f7bd9454cf 100644 --- a/app/javascript/flavours/glitch/hooks/useObserver.ts +++ b/app/javascript/flavours/glitch/hooks/useObserver.ts @@ -1,7 +1,7 @@ import { useEffect, useRef } from 'react'; export function useResizeObserver(callback: ResizeObserverCallback) { - const observerRef = useRef(null); + const observerRef = useRef(null); observerRef.current ??= new ResizeObserver(callback); useEffect(() => { @@ -15,7 +15,7 @@ export function useResizeObserver(callback: ResizeObserverCallback) { } export function useMutationObserver(callback: MutationCallback) { - const observerRef = useRef(null); + const observerRef = useRef(null); observerRef.current ??= new MutationObserver(callback); useEffect(() => { diff --git a/app/javascript/flavours/glitch/hooks/useOnClickOutside.ts b/app/javascript/flavours/glitch/hooks/useOnClickOutside.ts index ad964978c8..788441e7d9 100644 --- a/app/javascript/flavours/glitch/hooks/useOnClickOutside.ts +++ b/app/javascript/flavours/glitch/hooks/useOnClickOutside.ts @@ -2,10 +2,10 @@ * Handle clicks that occur outside of the element(s) provided in the first parameter */ -import type { MutableRefObject } from 'react'; +import type { RefObject } from 'react'; import { useEffect } from 'react'; -type ElementRef = MutableRefObject; +type ElementRef = RefObject; export function useOnClickOutside( excludedElementRef: ElementRef | ElementRef[] | null, diff --git a/app/javascript/flavours/glitch/hooks/useOverflow.ts b/app/javascript/flavours/glitch/hooks/useOverflow.ts index b85222cf56..40d9cd0775 100644 --- a/app/javascript/flavours/glitch/hooks/useOverflow.ts +++ b/app/javascript/flavours/glitch/hooks/useOverflow.ts @@ -1,4 +1,4 @@ -import type { MutableRefObject, RefCallback } from 'react'; +import type { RefObject, RefCallback } from 'react'; import { useState, useRef, useCallback, useEffect } from 'react'; import { useMutationObserver, useResizeObserver } from './useObserver'; @@ -20,7 +20,7 @@ export function useOverflowButton({ const [maxWidth, setMaxWidth] = useState('none'); // This is the item container element. - const listRef = useRef(null); + const listRef = useRef(null); // The main recalculation function. const handleRecalculate = useCallback(() => { @@ -102,7 +102,7 @@ export function useOverflowScroll({ const [canScrollLeft, setCanScrollLeft] = useState(false); const [canScrollRight, setCanScrollRight] = useState(false); - const bodyRef = useRef(null); + const bodyRef = useRef(null); // Recalculate scrollable state const handleRecalculate = useCallback(() => { @@ -176,13 +176,11 @@ export function useOverflowObservers({ onWrapperRef, }: { onRecalculate: () => void; - onListRef?: RefCallback | MutableRefObject; - onWrapperRef?: - | RefCallback - | MutableRefObject; + onListRef?: RefCallback | RefObject; + onWrapperRef?: RefCallback | RefObject; }) { // This is the item container element. - const listRef = useRef(null); + const listRef = useRef(null); const resizeObserver = useResizeObserver(onRecalculate); @@ -213,7 +211,7 @@ export function useOverflowObservers({ }, [handleChildrenChange, mutationObserver, resizeObserver]); // Watch the wrapper for size changes, and recalculate when it resizes. - const wrapperRef = useRef(null); + const wrapperRef = useRef(null); const wrapperRefCallback = useCallback( (node: HTMLElement | null) => { if (node) { diff --git a/app/javascript/flavours/glitch/hooks/useSearchAccounts.ts b/app/javascript/flavours/glitch/hooks/useSearchAccounts.ts index 06436bd96b..84b22eee46 100644 --- a/app/javascript/flavours/glitch/hooks/useSearchAccounts.ts +++ b/app/javascript/flavours/glitch/hooks/useSearchAccounts.ts @@ -30,7 +30,7 @@ export function useSearchAccounts({ 'idle' | 'loading' | 'error' >('idle'); - const searchRequestRef = useRef(null); + const searchRequestRef = useRef(null); const searchAccounts = useDebouncedCallback( async (value: string) => { diff --git a/app/javascript/flavours/glitch/hooks/useSearchTags.ts b/app/javascript/flavours/glitch/hooks/useSearchTags.ts index 157a434e52..51e81d6e33 100644 --- a/app/javascript/flavours/glitch/hooks/useSearchTags.ts +++ b/app/javascript/flavours/glitch/hooks/useSearchTags.ts @@ -44,7 +44,7 @@ export function useSearchTags({ 'idle' | 'loading' | 'error' >('idle'); - const searchRequestRef = useRef(null); + const searchRequestRef = useRef(null); const searchTags = useDebouncedCallback( (value: string) => { diff --git a/app/javascript/flavours/glitch/hooks/useSelectableClick.ts b/app/javascript/flavours/glitch/hooks/useSelectableClick.ts index c8f16f0b0f..10a589dafc 100644 --- a/app/javascript/flavours/glitch/hooks/useSelectableClick.ts +++ b/app/javascript/flavours/glitch/hooks/useSelectableClick.ts @@ -6,7 +6,7 @@ export const useSelectableClick = ( onClick: React.MouseEventHandler, maxDelta = 5, ) => { - const clickPositionRef = useRef(null); + const clickPositionRef = useRef(null); const handleMouseDown = useCallback((e: React.MouseEvent) => { clickPositionRef.current = [e.clientX, e.clientY]; diff --git a/app/javascript/flavours/glitch/hooks/useTimeout.ts b/app/javascript/flavours/glitch/hooks/useTimeout.ts index bb1e8848dd..285d98a4e8 100644 --- a/app/javascript/flavours/glitch/hooks/useTimeout.ts +++ b/app/javascript/flavours/glitch/hooks/useTimeout.ts @@ -1,8 +1,8 @@ import { useRef, useCallback, useEffect } from 'react'; export const useTimeout = () => { - const timeoutRef = useRef>(); - const callbackRef = useRef<() => void>(); + const timeoutRef = useRef>(null); + const callbackRef = useRef<() => void>(null); const set = useCallback((callback: () => void, delay: number) => { if (timeoutRef.current) { @@ -28,8 +28,8 @@ export const useTimeout = () => { const cancel = useCallback(() => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); - timeoutRef.current = undefined; - callbackRef.current = undefined; + timeoutRef.current = null; + callbackRef.current = null; } }, []); diff --git a/app/javascript/flavours/glitch/utils/html.ts b/app/javascript/flavours/glitch/utils/html.ts index dd2865f2e6..1b672d5c5b 100644 --- a/app/javascript/flavours/glitch/utils/html.ts +++ b/app/javascript/flavours/glitch/utils/html.ts @@ -20,7 +20,7 @@ interface AllowedTag { } type AllowedTagsType = { - [Tag in keyof React.ReactHTML]?: AllowedTag; + [Tag in keyof React.JSX.IntrinsicElements]?: AllowedTag; }; const globalAttributes: Record = htmlConfig.global; @@ -70,7 +70,7 @@ export function htmlStringToComponents>( const wrapper = document.createElement('template'); wrapper.innerHTML = htmlString; - const rootChildren: React.ReactNode[] = []; + const rootChildren: Awaited[] = []; const queue: QueueItem[] = [ { node: wrapper.content, parent: rootChildren, depth: 0 }, ];