Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { useMyStream } from "../../../../contexts/wave/MyStreamContext";
interface WebBrainLeftSidebarWavesProps {
readonly scrollContainerRef: React.RefObject<HTMLElement | null>;
readonly isCollapsed?: boolean | undefined;
readonly showProfileFeedShortcut?: boolean | undefined;
}

const WebBrainLeftSidebarWaves: React.FC<WebBrainLeftSidebarWavesProps> = ({
scrollContainerRef,
isCollapsed = false,
showProfileFeedShortcut = true,
}) => {


const { waves, registerWave } = useMyStream();

const onNextPage = () => {
Expand All @@ -31,6 +31,7 @@ const WebBrainLeftSidebarWaves: React.FC<WebBrainLeftSidebarWavesProps> = ({
onHover={registerWave}
scrollContainerRef={scrollContainerRef}
isCollapsed={isCollapsed}
showProfileFeedShortcut={showProfileFeedShortcut}
/>
);
};
Expand Down
19 changes: 8 additions & 11 deletions components/brain/left-sidebar/web/WebDirectMessagesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import PrimaryButton from "../../../utils/button/PrimaryButton";
import CreateDirectMessageModal from "../../../waves/create-dm/CreateDirectMessageModal";
import UnifiedWavesListEmpty from "../waves/UnifiedWavesListEmpty";
import { UnifiedWavesListLoader } from "../waves/UnifiedWavesListLoader";
import type { WebUnifiedWavesListWavesHandle } from "./WebUnifiedWavesListWaves";
import WebUnifiedWavesListWaves from "./WebUnifiedWavesListWaves";

interface WebDirectMessagesListProps {
Expand All @@ -37,15 +36,15 @@ const WebDirectMessagesList: React.FC<WebDirectMessagesListProps> = ({

const shouldRenderCreateDirectMessage = !isApp;

const listRef = useRef<WebUnifiedWavesListWavesHandle>(null);
const sentinelRef = useRef<HTMLDivElement>(null);
const { directMessages, registerWave } = useMyStream();

useInfiniteScroll(
directMessages.hasNextPage,
directMessages.isFetchingNextPage,
directMessages.fetchNextPage,
scrollContainerRef,
listRef.current?.sentinelRef || { current: null },
sentinelRef,
"100px"
);

Expand All @@ -70,7 +69,6 @@ const WebDirectMessagesList: React.FC<WebDirectMessagesListProps> = ({
} else {
listContent = (
<WebUnifiedWavesListWaves
ref={listRef}
waves={directMessages.list}
onHover={registerWave}
scrollContainerRef={scrollContainerRef}
Expand All @@ -79,6 +77,7 @@ const WebDirectMessagesList: React.FC<WebDirectMessagesListProps> = ({
hidePin={true}
basePath="/messages"
isCollapsed={isCollapsed}
sentinelRef={sentinelRef}
/>
);
}
Expand Down Expand Up @@ -204,13 +203,11 @@ const WebDirectMessagesList: React.FC<WebDirectMessagesListProps> = ({
/>
)}

{connectedProfile && (
<CreateDirectMessageModal
isOpen={isDirectMessageModalOpen}
onClose={close}
profile={connectedProfile}
/>
)}
<CreateDirectMessageModal
isOpen={isDirectMessageModalOpen}
onClose={close}
profile={connectedProfile}
/>
</div>
);
};
Expand Down
3 changes: 3 additions & 0 deletions components/brain/left-sidebar/web/WebLeftSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ChevronDoubleRightIcon } from "@heroicons/react/24/outline";
*/
interface WebLeftSidebarProps {
readonly isCollapsed?: boolean | undefined;
readonly showProfileFeedShortcut?: boolean | undefined;
}

const WebLeftSidebarQuickVoteOwner: React.FC<{
Expand All @@ -45,6 +46,7 @@ const WebLeftSidebarQuickVoteOwner: React.FC<{

const WebLeftSidebar: React.FC<WebLeftSidebarProps> = ({
isCollapsed = false,
showProfileFeedShortcut = true,
}) => {
const scrollContainerRef = useRef<HTMLDivElement>(null);
const pathname = usePathname();
Expand Down Expand Up @@ -93,6 +95,7 @@ const WebLeftSidebar: React.FC<WebLeftSidebarProps> = ({
<WebBrainLeftSidebarWaves
scrollContainerRef={scrollContainerRef}
isCollapsed={isCollapsed}
showProfileFeedShortcut={showProfileFeedShortcut}
/>
)}
{isMessagesView && (
Expand Down
11 changes: 6 additions & 5 deletions components/brain/left-sidebar/web/WebUnifiedWavesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, { useRef } from "react";
import { useInfiniteScroll } from "../../../../hooks/useInfiniteScroll";
import UnifiedWavesListEmpty from "../waves/UnifiedWavesListEmpty";
import { UnifiedWavesListLoader } from "../waves/UnifiedWavesListLoader";
import type { WebUnifiedWavesListWavesHandle } from "./WebUnifiedWavesListWaves";
import WebUnifiedWavesListWaves from "./WebUnifiedWavesListWaves";
import type { MinimalWave } from "@/contexts/wave/hooks/useEnhancedWavesListCore";

Expand All @@ -17,6 +16,7 @@ interface WebUnifiedWavesListProps {
readonly onHover: (waveId: string) => void;
readonly scrollContainerRef: React.RefObject<HTMLElement | null>;
readonly isCollapsed?: boolean | undefined;
readonly showProfileFeedShortcut?: boolean | undefined;
}

const WebUnifiedWavesList: React.FC<WebUnifiedWavesListProps> = (props) => {
Expand All @@ -29,17 +29,17 @@ const WebUnifiedWavesList: React.FC<WebUnifiedWavesListProps> = (props) => {
onHover,
scrollContainerRef,
isCollapsed = false,
showProfileFeedShortcut = true,
} = props;
// Refs to the scroll container and sentinel
const listRef = useRef<WebUnifiedWavesListWavesHandle>(null);
const sentinelRef = useRef<HTMLDivElement>(null);

// Use the custom hook for infinite scroll
useInfiniteScroll(
hasNextPage,
isFetchingNextPage,
fetchNextPage,
scrollContainerRef,
listRef.current?.sentinelRef || { current: null },
sentinelRef,
"100px"
);

Expand All @@ -48,11 +48,12 @@ const WebUnifiedWavesList: React.FC<WebUnifiedWavesListProps> = (props) => {
<div className="tw-w-full">
{/* Unified Waves List */}
<WebUnifiedWavesListWaves
ref={listRef}
waves={waves}
onHover={onHover}
scrollContainerRef={scrollContainerRef}
isCollapsed={isCollapsed}
showProfileFeedShortcut={showProfileFeedShortcut}
sentinelRef={sentinelRef}
/>

{/* Loading indicator and intersection trigger */}
Expand Down
Loading
Loading