fix: missing ExportMenuOptions in persist leads to useSelector re-render a lot (#4593)
* fix: missing ExportMenuOptions in persist leads to useSelector re-render * chore: cleanup
This commit is contained in:
parent
24e28b86cf
commit
10efa444bf
@ -70,20 +70,7 @@ const MessageMenubar: FC<Props> = (props) => {
|
|||||||
|
|
||||||
const isUserMessage = message.role === 'user'
|
const isUserMessage = message.role === 'user'
|
||||||
|
|
||||||
const exportMenuOptions = useSelector(
|
const exportMenuOptions = useSelector((state: RootState) => state.settings.exportMenuOptions)
|
||||||
(state: RootState) =>
|
|
||||||
state.settings.exportMenuOptions || {
|
|
||||||
image: true,
|
|
||||||
markdown: true,
|
|
||||||
markdown_reason: true,
|
|
||||||
notion: true,
|
|
||||||
yuque: true,
|
|
||||||
joplin: true,
|
|
||||||
obsidian: true,
|
|
||||||
siyuan: true,
|
|
||||||
docx: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const onCopy = useCallback(
|
const onCopy = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
|
|||||||
@ -156,20 +156,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
[setActiveTopic]
|
[setActiveTopic]
|
||||||
)
|
)
|
||||||
|
|
||||||
const exportMenuOptions = useSelector(
|
const exportMenuOptions = useSelector((state: RootState) => state.settings.exportMenuOptions)
|
||||||
(state: RootState) =>
|
|
||||||
state.settings.exportMenuOptions || {
|
|
||||||
image: true,
|
|
||||||
markdown: true,
|
|
||||||
markdown_reason: true,
|
|
||||||
notion: true,
|
|
||||||
yuque: true,
|
|
||||||
joplin: true,
|
|
||||||
obsidian: true,
|
|
||||||
siyuan: true,
|
|
||||||
docx: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const getTopicMenuItems = useCallback(
|
const getTopicMenuItems = useCallback(
|
||||||
(topic: Topic) => {
|
(topic: Topic) => {
|
||||||
|
|||||||
@ -13,20 +13,7 @@ const ExportMenuOptions: FC = () => {
|
|||||||
const { theme } = useTheme()
|
const { theme } = useTheme()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
const exportMenuOptions = useSelector(
|
const exportMenuOptions = useSelector((state: RootState) => state.settings.exportMenuOptions)
|
||||||
(state: RootState) =>
|
|
||||||
state.settings.exportMenuOptions || {
|
|
||||||
image: true,
|
|
||||||
markdown: true,
|
|
||||||
markdown_reason: true,
|
|
||||||
notion: true,
|
|
||||||
yuque: true,
|
|
||||||
joplin: true,
|
|
||||||
obsidian: true,
|
|
||||||
siyuan: true,
|
|
||||||
docx: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const handleToggleOption = (option: string, checked: boolean) => {
|
const handleToggleOption = (option: string, checked: boolean) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
|
|||||||
@ -42,7 +42,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 92,
|
version: 93,
|
||||||
blacklist: ['runtime', 'messages'],
|
blacklist: ['runtime', 'messages'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import { createMigrate } from 'redux-persist'
|
|||||||
import { RootState } from '.'
|
import { RootState } from '.'
|
||||||
import { INITIAL_PROVIDERS, moveProvider } from './llm'
|
import { INITIAL_PROVIDERS, moveProvider } from './llm'
|
||||||
import { mcpSlice } from './mcp'
|
import { mcpSlice } from './mcp'
|
||||||
import { DEFAULT_SIDEBAR_ICONS } from './settings'
|
import { DEFAULT_SIDEBAR_ICONS, initialState as settingsInitialState } from './settings'
|
||||||
|
|
||||||
// remove logo base64 data to reduce the size of the state
|
// remove logo base64 data to reduce the size of the state
|
||||||
function removeMiniAppIconsFromState(state: RootState) {
|
function removeMiniAppIconsFromState(state: RootState) {
|
||||||
@ -1173,6 +1173,17 @@ const migrateConfig = {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'93': (state: RootState) => {
|
||||||
|
try {
|
||||||
|
if (!state?.settings?.exportMenuOptions) {
|
||||||
|
state.settings.exportMenuOptions = settingsInitialState.exportMenuOptions
|
||||||
|
return state
|
||||||
|
}
|
||||||
|
return state
|
||||||
|
} catch (error) {
|
||||||
|
return state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,7 +125,7 @@ export interface SettingsState {
|
|||||||
|
|
||||||
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
export type MultiModelMessageStyle = 'horizontal' | 'vertical' | 'fold' | 'grid'
|
||||||
|
|
||||||
const initialState: SettingsState = {
|
export const initialState: SettingsState = {
|
||||||
showAssistants: true,
|
showAssistants: true,
|
||||||
showTopics: true,
|
showTopics: true,
|
||||||
sendMessageShortcut: 'Enter',
|
sendMessageShortcut: 'Enter',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user