mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-10-10 21:26:01 +02:00
improved mobile scroll (#3110)
This commit is contained in:
@@ -142,6 +142,16 @@ export function ChatPage({
|
|||||||
refreshChatSessions,
|
refreshChatSessions,
|
||||||
} = useChatContext();
|
} = useChatContext();
|
||||||
|
|
||||||
|
// handle redirect if chat page is disabled
|
||||||
|
// NOTE: this must be done here, in a client component since
|
||||||
|
// settings are passed in via Context and therefore aren't
|
||||||
|
// available in server-side components
|
||||||
|
const settings = useContext(SettingsContext);
|
||||||
|
const enterpriseSettings = settings?.enterpriseSettings;
|
||||||
|
if (settings?.settings?.chat_page_enabled === false) {
|
||||||
|
router.push("/search");
|
||||||
|
}
|
||||||
|
|
||||||
const { assistants: availableAssistants, finalAssistants } = useAssistants();
|
const { assistants: availableAssistants, finalAssistants } = useAssistants();
|
||||||
|
|
||||||
const [showApiKeyModal, setShowApiKeyModal] = useState(
|
const [showApiKeyModal, setShowApiKeyModal] = useState(
|
||||||
@@ -881,7 +891,6 @@ export function ChatPage({
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
};
|
};
|
||||||
|
|
||||||
const distance = 500; // distance that should "engage" the scroll
|
|
||||||
const debounceNumber = 100; // time for debouncing
|
const debounceNumber = 100; // time for debouncing
|
||||||
|
|
||||||
const [hasPerformedInitialScroll, setHasPerformedInitialScroll] = useState(
|
const [hasPerformedInitialScroll, setHasPerformedInitialScroll] = useState(
|
||||||
@@ -1545,17 +1554,6 @@ export function ChatPage({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// handle redirect if chat page is disabled
|
|
||||||
// NOTE: this must be done here, in a client component since
|
|
||||||
// settings are passed in via Context and therefore aren't
|
|
||||||
// available in server-side components
|
|
||||||
const settings = useContext(SettingsContext);
|
|
||||||
const enterpriseSettings = settings?.enterpriseSettings;
|
|
||||||
if (settings?.settings?.chat_page_enabled === false) {
|
|
||||||
router.push("/search");
|
|
||||||
}
|
|
||||||
|
|
||||||
const [showDocSidebar, setShowDocSidebar] = useState(false); // State to track if sidebar is open
|
const [showDocSidebar, setShowDocSidebar] = useState(false); // State to track if sidebar is open
|
||||||
|
|
||||||
// Used to maintain a "time out" for history sidebar so our existing refs can have time to process change
|
// Used to maintain a "time out" for history sidebar so our existing refs can have time to process change
|
||||||
@@ -1603,9 +1601,9 @@ export function ChatPage({
|
|||||||
scrollableDivRef,
|
scrollableDivRef,
|
||||||
scrollDist,
|
scrollDist,
|
||||||
endDivRef,
|
endDivRef,
|
||||||
distance,
|
|
||||||
debounceNumber,
|
debounceNumber,
|
||||||
waitForScrollRef,
|
waitForScrollRef,
|
||||||
|
mobile: settings?.isMobile,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Virtualization + Scrolling related effects and functions
|
// Virtualization + Scrolling related effects and functions
|
||||||
|
@@ -639,19 +639,22 @@ export async function useScrollonStream({
|
|||||||
scrollableDivRef,
|
scrollableDivRef,
|
||||||
scrollDist,
|
scrollDist,
|
||||||
endDivRef,
|
endDivRef,
|
||||||
distance,
|
|
||||||
debounceNumber,
|
debounceNumber,
|
||||||
waitForScrollRef,
|
mobile,
|
||||||
}: {
|
}: {
|
||||||
chatState: ChatState;
|
chatState: ChatState;
|
||||||
scrollableDivRef: RefObject<HTMLDivElement>;
|
scrollableDivRef: RefObject<HTMLDivElement>;
|
||||||
waitForScrollRef: RefObject<boolean>;
|
waitForScrollRef: RefObject<boolean>;
|
||||||
scrollDist: MutableRefObject<number>;
|
scrollDist: MutableRefObject<number>;
|
||||||
endDivRef: RefObject<HTMLDivElement>;
|
endDivRef: RefObject<HTMLDivElement>;
|
||||||
distance: number;
|
|
||||||
debounceNumber: number;
|
debounceNumber: number;
|
||||||
mobile?: boolean;
|
mobile?: boolean;
|
||||||
}) {
|
}) {
|
||||||
|
const mobileDistance = 900; // distance that should "engage" the scroll
|
||||||
|
const desktopDistance = 500; // distance that should "engage" the scroll
|
||||||
|
|
||||||
|
const distance = mobile ? mobileDistance : desktopDistance;
|
||||||
|
|
||||||
const preventScrollInterference = useRef<boolean>(false);
|
const preventScrollInterference = useRef<boolean>(false);
|
||||||
const preventScroll = useRef<boolean>(false);
|
const preventScroll = useRef<boolean>(false);
|
||||||
const blockActionRef = useRef<boolean>(false);
|
const blockActionRef = useRef<boolean>(false);
|
||||||
@@ -692,7 +695,7 @@ export async function useScrollonStream({
|
|||||||
endDivRef.current
|
endDivRef.current
|
||||||
) {
|
) {
|
||||||
// catch up if necessary!
|
// catch up if necessary!
|
||||||
const scrollAmount = scrollDist.current + 10000;
|
const scrollAmount = scrollDist.current + (mobile ? 1000 : 10000);
|
||||||
if (scrollDist.current > 300) {
|
if (scrollDist.current > 300) {
|
||||||
// if (scrollDist.current > 140) {
|
// if (scrollDist.current > 140) {
|
||||||
endDivRef.current.scrollIntoView();
|
endDivRef.current.scrollIntoView();
|
||||||
|
Reference in New Issue
Block a user