Skip to content

Commit f79932f

Browse files
berry-13danny-avila
authored andcommitted
🖱️ feat: Switch Scroll Button setting (#5332)
1 parent 57465e1 commit f79932f

File tree

6 files changed

+46
-2
lines changed

6 files changed

+46
-2
lines changed

client/src/components/Chat/Messages/MessagesView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default function MessagesView({
1717
Header?: ReactNode;
1818
}) {
1919
const localize = useLocalize();
20+
const scrollButtonPreference = useRecoilValue(store.showScrollButton);
2021
const fontSize = useRecoilValue(store.fontSize);
2122
const { screenshotTargetRef } = useScreenshot();
2223
const [currentEditId, setCurrentEditId] = useState<number | string | null>(-1);
@@ -83,7 +84,10 @@ export default function MessagesView({
8384
unmountOnExit={false}
8485
// appear
8586
>
86-
{() => showScrollButton && <ScrollToBottom scrollHandler={handleSmoothToRef} />}
87+
{() =>
88+
showScrollButton &&
89+
scrollButtonPreference && <ScrollToBottom scrollHandler={handleSmoothToRef} />
90+
}
8791
</CSSTransition>
8892
</div>
8993
</div>

client/src/components/Nav/SettingsTabs/Chat/Chat.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ForkSettings } from './ForkSettings';
77
import ChatDirection from './ChatDirection';
88
import ShowThinking from './ShowThinking';
99
import LaTeXParsing from './LaTeXParsing';
10+
import ScrollButton from './ScrollButton';
1011
import ModularChat from './ModularChat';
1112
import SaveDraft from './SaveDraft';
1213

@@ -31,6 +32,9 @@ function Chat() {
3132
<div className="pb-3">
3233
<SaveDraft />
3334
</div>
35+
<div className="pb-3">
36+
<ScrollButton />
37+
</div>
3438
<ForkSettings />
3539
<div className="pb-3">
3640
<ModularChat />

client/src/components/Nav/SettingsTabs/Chat/MaximizeChatSpace.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useRecoilState } from 'recoil';
2-
import HoverCardSettings from '../HoverCardSettings';
32
import { Switch } from '~/components/ui/Switch';
43
import useLocalize from '~/hooks/useLocalize';
54
import store from '~/store';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useRecoilState } from 'recoil';
2+
import { Switch } from '~/components/ui/Switch';
3+
import useLocalize from '~/hooks/useLocalize';
4+
import store from '~/store';
5+
6+
export default function ScrollButton({
7+
onCheckedChange,
8+
}: {
9+
onCheckedChange?: (value: boolean) => void;
10+
}) {
11+
const [showScrollButton, setShowScrollButton] = useRecoilState<boolean>(store.showScrollButton);
12+
const localize = useLocalize();
13+
14+
const handleCheckedChange = (value: boolean) => {
15+
setShowScrollButton(value);
16+
if (onCheckedChange) {
17+
onCheckedChange(value);
18+
}
19+
};
20+
21+
return (
22+
<div className="flex items-center justify-between">
23+
<div className="flex items-center space-x-2">
24+
<div>{localize('com_nav_scroll_button')}</div>
25+
</div>
26+
<Switch
27+
id="scrollButton"
28+
checked={showScrollButton}
29+
onCheckedChange={handleCheckedChange}
30+
className="ml-4"
31+
data-testid="scrollButton"
32+
/>
33+
</div>
34+
);
35+
}

client/src/localization/languages/Eng.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ export default {
882882
com_nav_command_settings: 'Command Settings',
883883
com_nav_command_settings_description: 'Customize which commands are available in the chat',
884884
com_nav_no_search_results: 'No search results found',
885+
com_nav_scroll_button: 'Scroll to the end button',
885886
com_nav_setting_general: 'General',
886887
com_nav_setting_chat: 'Chat',
887888
com_nav_setting_beta: 'Beta features',

client/src/store/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const localStorageAtoms = {
3333
chatDirection: atomWithLocalStorage('chatDirection', 'LTR'),
3434
showCode: atomWithLocalStorage(LocalStorageKeys.SHOW_ANALYSIS_CODE, true),
3535
saveDrafts: atomWithLocalStorage('saveDrafts', true),
36+
showScrollButton: atomWithLocalStorage('showScrollButton', true),
3637
forkSetting: atomWithLocalStorage('forkSetting', ''),
3738
splitAtTarget: atomWithLocalStorage('splitAtTarget', false),
3839
rememberDefaultFork: atomWithLocalStorage(LocalStorageKeys.REMEMBER_FORK_OPTION, false),

0 commit comments

Comments
 (0)