Skip to content

Commit

Permalink
✨ feat: 优化保存为话题功能
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jul 30, 2023
1 parent 451f86f commit fdbe084
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ config.extends.push('plugin:@next/next/recommended');

config.rules['unicorn/no-negated-condition'] = 0;
config.rules['unicorn/prefer-type-error'] = 0;
config.rules['unicorn/prefer-logical-operator-over-ternary'] = 0;
config.rules['unicorn/no-null'] = 0;

module.exports = config;
17 changes: 7 additions & 10 deletions src/pages/chat/[id]/Conversation/Input/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ChatInputArea, DraggablePanel, Icon, Tooltip } from '@lobehub/ui';
import { Button } from 'antd';
import { LucideGalleryVerticalEnd } from 'lucide-react';
import { memo, useMemo, useState } from 'react';
import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { shallow } from 'zustand/shallow';

Expand All @@ -18,18 +18,15 @@ const ChatInput = () => {
const [text, setText] = useState('');

const [inputHeight] = useSettings((s) => [s.inputHeight], shallow);
const [sendMessage, saveToTopic] = useSessionStore(
(s) => [s.createOrSendMsg, s.saveToTopic],
const [sendMessage, hasTopic, saveToTopic] = useSessionStore(
(s) => [s.createOrSendMsg, !!s.activeTopicId, s.saveToTopic],
shallow,
);

const footer = useMemo(
() => (
<Tooltip title={t('topic.saveCurrentMessages')}>
<Button icon={<Icon icon={LucideGalleryVerticalEnd} />} onClick={saveToTopic} />
</Tooltip>
),
[],
const footer = hasTopic ? null : (
<Tooltip title={t('topic.saveCurrentMessages')}>
<Button icon={<Icon icon={LucideGalleryVerticalEnd} />} onClick={saveToTopic} />
</Tooltip>
);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/store/settings/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const createSettings: StateCreator<
setSettings({
...settings,
// 如果用户存在用户头像,那么不做导入
avatar: get().settings.avatar ?? settings.avatar,
avatar: !get().settings.avatar ? settings.avatar : get().settings.avatar,
});
},
resetSettings: () => {
Expand Down

0 comments on commit fdbe084

Please sign in to comment.