Skip to content

Commit

Permalink
fix feedback banner hydration issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GwonHyeok committed Feb 20, 2025
1 parent b93b8ab commit 72187f4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/chat/[id]/screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ export default function Screen(
const [isJsonViewerOpen, setIsJsonViewerOpen] = useState(false);
const [isLeftSidebarOpen, setIsLeftSidebarOpen] = useState(!isMobile);
const [isRightSidebarOpen, setIsRightSidebarOpen] = useState(!isMobile);
const [showFeedbackBanner, setShowFeedbackBanner] = useState(() => {
if (typeof window === 'undefined') return true;
return localStorage.getItem('feedbackBannerClosed') !== 'true';
});
const [showFeedbackBanner, setShowFeedbackBanner] = useState<boolean>();

const {data, mutate} = useSWR<ChatMessageListResponse>(`/api/chat-rooms/${id}/messages`, async (url: string) => {
const response = await fetch(url);
return response.json();
});
const messages = useMemo(() => data?.chatMessages || [], [data]);

useEffect(() => {
if (showFeedbackBanner === undefined) {
setShowFeedbackBanner(!localStorage.getItem('feedbackBannerClosed'));
}
}, [showFeedbackBanner]);

useEffect(() => {
if (messagesEndRef.current) {
messagesEndRef.current.scrollIntoView({behavior: 'smooth'});
Expand Down

0 comments on commit 72187f4

Please sign in to comment.