diff --git a/packages/appreader/src/index.jsx b/packages/appreader/src/index.jsx index 8dde91f96..424bb517e 100644 --- a/packages/appreader/src/index.jsx +++ b/packages/appreader/src/index.jsx @@ -36,7 +36,6 @@ const App = () => { toolbarControl?: JSX.Element alwaysDisplayToolbar?: boolean setShowLogoutConfirmation: (showShareModal: boolean) => void @@ -48,19 +43,26 @@ export function PrimaryHeader(props: HeaderProps): JSX.Element { }) ) - const setScrollWatchedElement = useScrollWatcher( - (changeset: ScrollOffsetChangeset) => { - const isScrolledBeyondMinThreshold = changeset.current.y >= 50 - const isScrollingDown = changeset.current.y > changeset.previous.y +/* + useRegisterActions([ + { + id: 'lightTheme', + section: 'Preferences', + name: 'Change theme (lighter) ', + shortcut: ['v', 'l'], + keywords: 'light theme', + perform: () => lightenTheme(), }, - 0 - ) - - useEffect(() => { - if (props.scrollElementRef) { - setScrollWatchedElement(props.scrollElementRef.current) - } - }, [props.scrollElementRef, setScrollWatchedElement]) + { + id: 'darkTheme', + section: 'Preferences', + name: 'Change theme (darker) ', + shortcut: ['v', 'd'], + keywords: 'dark theme', + perform: () => darkenTheme(), + }, + ]) + */ const initAnalytics = useCallback(() => { setupAnalytics(props.user) diff --git a/packages/web/components/templates/PrimaryLayout.tsx b/packages/web/components/templates/PrimaryLayout.tsx index 973529cf3..295e7e1a8 100644 --- a/packages/web/components/templates/PrimaryLayout.tsx +++ b/packages/web/components/templates/PrimaryLayout.tsx @@ -21,7 +21,6 @@ type PrimaryLayoutProps = { pageTestId: string hideHeader?: boolean pageMetaDataProps?: PageMetaDataProps - scrollElementRef?: MutableRefObject headerToolbarControl?: JSX.Element alwaysDisplayToolbar?: boolean } @@ -63,8 +62,8 @@ export function PrimaryLayout(props: PrimaryLayoutProps): JSX.Element { ) : null} - - scrollElementRef: MutableRefObject articleMutations: ArticleMutations } @@ -89,16 +88,9 @@ export function Article(props: ArticleProps): JSX.Element { } }, [readingProgress]) - const setScrollWatchedElement = useScrollWatcher( + useScrollWatcher( (changeset: ScrollOffsetChangeset) => { - const scrollContainer = props.scrollElementRef.current - if (scrollContainer) { - const newReadingProgress = - (changeset.current.y + scrollContainer.clientHeight) / - scrollContainer.scrollHeight - - debouncedSetReadingProgress(newReadingProgress * 100) - } else if (window && window.document.scrollingElement) { + if (window && window.document.scrollingElement) { const newReadingProgress = window.scrollY / window.document.scrollingElement.scrollHeight const adjustedReadingProgress = @@ -131,10 +123,6 @@ export function Article(props: ArticleProps): JSX.Element { [] ) - useEffect(() => { - setScrollWatchedElement(props.scrollElementRef.current) - }, [props.scrollElementRef, setScrollWatchedElement]) - // Scroll to initial anchor position useEffect(() => { if (typeof window === 'undefined') { @@ -175,17 +163,11 @@ export function Article(props: ArticleProps): JSX.Element { } const calculatedOffset = calculateOffset(anchorElement) - - if (props.scrollElementRef.current) { - props.scrollElementRef.current?.scroll(0, calculatedOffset - 100) - } else { - window.document.documentElement.scroll(0, calculatedOffset - 100) - } + window.document.documentElement.scroll(0, calculatedOffset - 100) } } }, [ props.highlightReady, - props.scrollElementRef, props.initialAnchorIndex, props.initialReadingProgress, shouldScrollToInitialPosition, diff --git a/packages/web/components/templates/article/ArticleContainer.tsx b/packages/web/components/templates/article/ArticleContainer.tsx index 1811e9cf0..a79e415c6 100644 --- a/packages/web/components/templates/article/ArticleContainer.tsx +++ b/packages/web/components/templates/article/ArticleContainer.tsx @@ -24,7 +24,6 @@ type ArticleContainerProps = { article: ArticleAttributes labels: Label[] articleMutations: ArticleMutations - scrollElementRef: MutableRefObject isAppleAppEmbed: boolean highlightBarDisabled: boolean highlightsBaseURL: string @@ -281,7 +280,6 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element { articleId={props.article.id} content={props.article.content} initialAnchorIndex={props.article.readingProgressAnchorIndex} - scrollElementRef={props.scrollElementRef} articleMutations={props.articleMutations} />