
diff --git a/app/javascript/flavours/glitch/features/home_timeline/components/inline_follow_suggestions.tsx b/app/javascript/flavours/glitch/features/home_timeline/components/inline_follow_suggestions.tsx
index 677e8edf05..14e5b5d71c 100644
--- a/app/javascript/flavours/glitch/features/home_timeline/components/inline_follow_suggestions.tsx
+++ b/app/javascript/flavours/glitch/features/home_timeline/components/inline_follow_suggestions.tsx
@@ -1,9 +1,10 @@
-import { useEffect, useCallback, useRef, useState, useId } from 'react';
+import { useEffect, useCallback, useId } from 'react';
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
import { Link } from 'react-router-dom';
+import { useOverflowScroll } from '@/flavours/glitch/hooks/useOverflow';
import ChevronLeftIcon from '@/material-icons/400-24px/chevron_left.svg?react';
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
@@ -178,74 +179,24 @@ export const InlineFollowSuggestions: React.FC<{ hidden?: boolean }> = ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
state.settings.getIn(['dismissed_banners', DISMISSIBLE_ID]) as boolean,
);
- const bodyRef = useRef
(null);
- const [canScrollLeft, setCanScrollLeft] = useState(false);
- const [canScrollRight, setCanScrollRight] = useState(true);
useEffect(() => {
void dispatch(fetchSuggestions());
}, [dispatch]);
- useEffect(() => {
- if (!bodyRef.current) {
- return;
- }
-
- if (getComputedStyle(bodyRef.current).direction === 'rtl') {
- setCanScrollLeft(
- bodyRef.current.clientWidth - bodyRef.current.scrollLeft <
- bodyRef.current.scrollWidth,
- );
- setCanScrollRight(bodyRef.current.scrollLeft < 0);
- } else {
- setCanScrollLeft(bodyRef.current.scrollLeft > 0);
- setCanScrollRight(
- bodyRef.current.scrollLeft + bodyRef.current.clientWidth <
- bodyRef.current.scrollWidth,
- );
- }
- }, [setCanScrollRight, setCanScrollLeft, suggestions]);
-
- const handleLeftNav = useCallback(() => {
- if (!bodyRef.current) {
- return;
- }
-
- bodyRef.current.scrollLeft -= 200;
- }, []);
-
- const handleRightNav = useCallback(() => {
- if (!bodyRef.current) {
- return;
- }
-
- bodyRef.current.scrollLeft += 200;
- }, []);
-
- const handleScroll = useCallback(() => {
- if (!bodyRef.current) {
- return;
- }
-
- if (getComputedStyle(bodyRef.current).direction === 'rtl') {
- setCanScrollLeft(
- bodyRef.current.clientWidth - bodyRef.current.scrollLeft <
- bodyRef.current.scrollWidth,
- );
- setCanScrollRight(bodyRef.current.scrollLeft < 0);
- } else {
- setCanScrollLeft(bodyRef.current.scrollLeft > 0);
- setCanScrollRight(
- bodyRef.current.scrollLeft + bodyRef.current.clientWidth <
- bodyRef.current.scrollWidth,
- );
- }
- }, [setCanScrollRight, setCanScrollLeft]);
-
const handleDismiss = useCallback(() => {
dispatch(changeSetting(['dismissed_banners', DISMISSIBLE_ID], true));
}, [dispatch]);
+ const {
+ bodyRef,
+ handleScroll,
+ canScrollLeft,
+ canScrollRight,
+ handleLeftNav,
+ handleRightNav,
+ } = useOverflowScroll({ absoluteDistance: true });
+
if (dismissed || (!isLoading && suggestions.length === 0)) {
return null;
}
diff --git a/app/javascript/flavours/glitch/features/navigation_panel/components/disabled_account_banner.tsx b/app/javascript/flavours/glitch/features/navigation_panel/components/disabled_account_banner.tsx
index fd93aa0bf6..587ca963e0 100644
--- a/app/javascript/flavours/glitch/features/navigation_panel/components/disabled_account_banner.tsx
+++ b/app/javascript/flavours/glitch/features/navigation_panel/components/disabled_account_banner.tsx
@@ -75,7 +75,7 @@ export const DisabledAccountBanner: React.FC = () => {
diff --git a/app/javascript/flavours/glitch/features/ui/components/bundle_column_error.jsx b/app/javascript/flavours/glitch/features/ui/components/bundle_column_error.jsx
index 8578cb299b..b41a152792 100644
--- a/app/javascript/flavours/glitch/features/ui/components/bundle_column_error.jsx
+++ b/app/javascript/flavours/glitch/features/ui/components/bundle_column_error.jsx
@@ -98,7 +98,7 @@ class BundleColumnError extends PureComponent {