add show helptext user config value

This commit is contained in:
Simon
2025-01-26 16:18:45 +07:00
parent c633544eac
commit d408b5bb52
4 changed files with 34 additions and 5 deletions

View File

@@ -27,6 +27,7 @@ export type UserConfigType = {
hide_watched: boolean;
show_ignored_only: boolean;
show_subed_only: boolean;
show_help_text: boolean;
};
const updateUserConfig = async (config: Partial<UserConfigType>): Promise<UserConfigType> => {

View File

@@ -7,6 +7,7 @@ import Button from '../components/Button';
import useIsAdmin from '../functions/useIsAdmin';
import { useUserConfigStore } from '../stores/UserConfigStore';
import { useEffect, useState } from 'react';
import ToggleConfig from '../components/ToggleConfig';
const SettingsUser = () => {
const { userConfig, setPartialConfig } = useUserConfigStore();
@@ -16,13 +17,15 @@ const SettingsUser = () => {
const [styleSheet, setStyleSheet] = useState<ColourVariants>(userConfig.config.stylesheet);
const [styleSheetRefresh, setStyleSheetRefresh] = useState(false);
const [pageSize, setPageSize] = useState<number>(userConfig.config.page_size);
const [showHelpText, setShowHelpText] = useState(userConfig.config.show_help_text);
useEffect(() => {
(async () => {
setStyleSheet(userConfig.config.stylesheet);
setPageSize(userConfig.config.page_size);
setShowHelpText(userConfig.config.show_help_text);
})();
}, [userConfig.config.page_size, userConfig.config.stylesheet]);
}, [userConfig.config.page_size, userConfig.config.stylesheet, userConfig.config.show_help_text]);
const handleStyleSheetChange = async (selectedStyleSheet: ColourVariants) => {
setPartialConfig({ stylesheet: selectedStyleSheet });
@@ -34,6 +37,10 @@ const SettingsUser = () => {
setPartialConfig({ page_size: pageSize });
};
const handleShowHelpTextChange = async (configKey: string, configValue: boolean) => {
setPartialConfig({ [configKey]: configValue });
};
const handlePageRefresh = () => {
navigate(0);
setStyleSheetRefresh(false);
@@ -103,6 +110,16 @@ const SettingsUser = () => {
</div>
</div>
</div>
<div className="settings-box-wrapper">
<div>
<p>Show help text</p>
</div>
<ToggleConfig
name="show_help_text"
value={showHelpText}
updateCallback={handleShowHelpTextChange}
/>
</div>
</div>
</div>
{isAdmin && (

View File

@@ -29,6 +29,7 @@ export const useUserConfigStore = create<UserConfigState>(set => ({
hide_watched: false,
show_ignored_only: false,
show_subed_only: false,
show_help_text: true,
},
},
setUserConfig: userConfig => set({ userConfig }),