Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kulgg committed Jun 28, 2023
1 parent 21a95b4 commit 50671b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/[handle]/FetchData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function FetchData({ handle }: { handle: string }) {
const { toast } = useToast();

useEffect(() => {
console.log("Initial useEffect");
if (accountName != handle) {
scrollTo({ top: 0 });
setAccountName(handle);
setAccountStatus("");
setNumStatusResponses(0);
Expand Down
6 changes: 4 additions & 2 deletions app/[handle]/Tweets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
twitterStatusQueueAtom,
settingsAtom,
isAutoScrollAtom,
accountNameAtom,
} from "@/lib/atoms";
import { ITweetMap } from "@/lib/filter";
import useFetchQueue from "@/lib/hooks/use-fetch-queue";
Expand All @@ -26,6 +27,7 @@ import React, {
function Tweets({ handle }: { handle: string }) {
const bottomElementRef = useRef<HTMLDivElement>(null);
const isAutoScroll = useAtomValue(isAutoScrollAtom);
const accountName = useAtomValue(accountNameAtom);

const [archiveMap, setArchiveMap] = useAtom(archivedTweetsAtom);
const [twitterStatusQueue, setTwitterStatusQueue] = useAtom(
Expand Down Expand Up @@ -103,14 +105,14 @@ function Tweets({ handle }: { handle: string }) {
});

useEffect(() => {
if (isAutoScroll) {
if (isAutoScroll && results.length > 0 && accountName === handle) {
bottomElementRef.current?.scrollIntoView({
behavior: "smooth",
inline: "nearest",
block: "center",
});
}
}, [results, isAutoScroll]);
}, [results, isAutoScroll, accountName, handle]);

return (
<div>
Expand Down

0 comments on commit 50671b2

Please sign in to comment.