Skip to content

Commit

Permalink
Revert "feat: add clear messages confirm modal"
Browse files Browse the repository at this point in the history
This reverts commit 3588f2d.
  • Loading branch information
ddiu8081 committed May 22, 2023
1 parent 3588f2d commit bb2d370
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 61 deletions.
12 changes: 2 additions & 10 deletions src/components/header/ConversationMessageClearButton.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
import { useStore } from '@nanostores/solid'
import { currentConversationId } from '@/stores/conversation'
import {
scrollController,
showConfirmModal,
} from '@/stores/ui'
import { scrollController } from '@/stores/ui'
import { clearMessagesByConversationId } from '@/stores/messages'
import { useI18n } from '@/hooks'
import ConfirmModal from '../ui/ConfirmModal'

export default () => {
const $currentConversationId = useStore(currentConversationId)
const { t } = useI18n()

const handleClearMessage = () => {
clearMessagesByConversationId($currentConversationId())
scrollController().scrollToBottom()
showConfirmModal.set(false)
}

return (
<>
{ $currentConversationId() && (
<div
class="fcc p-2 rounded-md text-xl hv-foreground"
onClick={() => { showConfirmModal.set(true) }}
onClick={handleClearMessage}
>
<div i-carbon-clean />
</div>
)}
<ConfirmModal title={t('conversations.confirm.title')} description={t('conversations.confirm.desc')} onConfirm={handleClearMessage} onCancel={() => { showConfirmModal.set(false) }} />
</>
)
}
5 changes: 3 additions & 2 deletions src/components/main/Conversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default () => {
<Switch
fallback={(
<Welcome />
)}
)}
>
<Match when={$currentConversationId() && !currentConversationMessages().length}>
<ConversationEmpty conversation={currentConversation()} />
Expand All @@ -52,8 +52,9 @@ export default () => {
</Match>
<Match when={currentBot()?.type === 'image_generation'}>
<Image
// conversationId={$currentConversationId()}
// conversationId={$currentConversationId()}
messages={currentConversationMessages}
// fetching={isLoading() || !isStreaming()}
/>
</Match>
</Switch>
Expand Down
29 changes: 0 additions & 29 deletions src/components/ui/ConfirmModal.tsx

This file was deleted.

7 changes: 3 additions & 4 deletions src/components/ui/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface Props {
direction: 'top' | 'bottom' | 'left' | 'right'
children: JSXElement
closeBtnClass?: string
hiddenCloseIcon?: boolean
}

export default (props: Props) => {
Expand Down Expand Up @@ -46,9 +45,9 @@ export default (props: Props) => {
</Portal>
<div {...api().containerProps}>
<div {...api().contentProps} class={`bg-modal transition-transform ease-out max-w-screen max-h-screen overflow-auto border-base shadow-lg ring-0 outline-none ${containerBaseClass}`}>
{
!props.hiddenCloseIcon && <button {...api().closeTriggerProps} class={`absolute p-1 rounded-md top-4 right-4 hv-base hv-foreground ${props.closeBtnClass || ''}`}> <div i-carbon-close class="text-xl" /></button>
}
<button {...api().closeTriggerProps} class={`absolute p-1 rounded-md top-4 right-4 hv-base hv-foreground ${props.closeBtnClass || ''}`}>
<div i-carbon-close class="text-xl" />
</button>
{ props.children }
</div>
</div>
Expand Down
7 changes: 0 additions & 7 deletions src/locale/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export const en = {
recent: 'Recents',
noRecent: 'No recents',
untitled: 'Untitled',
confirm: {
title: 'Delete all messages in this chat',
desc: 'This action cannot be undone.',
message: 'Delete this record',
btn: 'confirm',
cancel: 'cancel',
},
},
send: {
placeholder: 'Enter Something...',
Expand Down
7 changes: 0 additions & 7 deletions src/locale/lang/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export const zhCN = {
recent: '最近对话',
noRecent: '暂无最近对话',
untitled: '未命名对话',
confirm: {
title: '删除本会话的所有消息',
desc: '这将删除本会话的所有消息,且不可恢复',
message: '删除这条记录',
btn: '确认',
cancel: '取消',
},
},
send: {
placeholder: '输入内容...',
Expand Down
1 change: 0 additions & 1 deletion src/stores/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const showConversationSidebar = atom(false)
export const showSettingsSidebar = atom(false)
export const showConversationEditModal = atom(false)
export const showEmojiPickerModal = atom(false)
export const showConfirmModal = atom(false)

export const isSendBoxFocus = atom(false)
export const currentErrorMessage = atom<ErrorMessage | null>(null)
Expand Down
1 change: 0 additions & 1 deletion unocss.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default defineConfig({
'hv-foreground': 'transition-opacity cursor-pointer op-70 hover:op-100',
'input-base': 'bg-transparent placeholder:op-50 dark:placeholder:op-20 focus:(ring-0 outline-none) resize-none',
'button': 'mt-4 px-3 py-2 text-xs border border-base rounded-lg hv-base hover:border-base-100',
'emerald-button': 'mt-4 px-3 py-2 text-xs border rounded-lg text-light-400 border-emerald-600 bg-emerald-600 hover-bg-emerald-700 hover-border-emerald-700',
'max-w-base': 'max-w-3xl mx-auto',
'text-error': 'text-red-700 dark:text-red-400/80',
'border-error': 'border border-red-700 dark:border-red-400/80',
Expand Down

0 comments on commit bb2d370

Please sign in to comment.