Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
e6bad93b
authored
Sep 26, 2024
by
papapatrick
Committed by
GitHub
Sep 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: mobile history slider records disappear (#2806)
* fix: mobile history slider records disappear * change h
parent
12d7ba5d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
25 deletions
+14
-25
projects/app/src/pages/chat/components/ChatHistorySlider.tsx
+5
-7
projects/app/src/web/core/chat/context/chatContext.tsx
+9
-18
No files found.
projects/app/src/pages/chat/components/ChatHistorySlider.tsx
View file @
e6bad93b
...
@@ -53,14 +53,12 @@ const ChatHistorySlider = ({
...
@@ -53,14 +53,12 @@ const ChatHistorySlider = ({
onChangeChatId
,
onChangeChatId
,
chatId
:
activeChatId
,
chatId
:
activeChatId
,
isLoading
,
isLoading
,
ScrollList
,
ScrollData
,
historyList
,
histories
histories
}
=
useContextSelector
(
ChatContext
,
(
v
)
=>
v
);
}
=
useContextSelector
(
ChatContext
,
(
v
)
=>
v
);
const
concatHistory
=
useMemo
(()
=>
{
const
concatHistory
=
useMemo
(()
=>
{
const
formatHistories
:
HistoryItemType
[]
=
historyList
.
map
((
data
)
=>
{
const
formatHistories
:
HistoryItemType
[]
=
histories
.
map
((
item
)
=>
{
const
item
=
data
.
data
;
return
{
id
:
item
.
chatId
,
title
:
item
.
title
,
customTitle
:
item
.
customTitle
,
top
:
item
.
top
};
return
{
id
:
item
.
chatId
,
title
:
item
.
title
,
customTitle
:
item
.
customTitle
,
top
:
item
.
top
};
});
});
const
newChat
:
HistoryItemType
=
{
const
newChat
:
HistoryItemType
=
{
...
@@ -70,7 +68,7 @@ const ChatHistorySlider = ({
...
@@ -70,7 +68,7 @@ const ChatHistorySlider = ({
const
activeChat
=
histories
.
find
((
item
)
=>
item
.
chatId
===
activeChatId
);
const
activeChat
=
histories
.
find
((
item
)
=>
item
.
chatId
===
activeChatId
);
return
!
activeChat
?
[
newChat
].
concat
(
formatHistories
)
:
formatHistories
;
return
!
activeChat
?
[
newChat
].
concat
(
formatHistories
)
:
formatHistories
;
},
[
activeChatId
,
histories
,
historyList
,
t
]);
},
[
activeChatId
,
histories
,
t
]);
// custom title edit
// custom title edit
const
{
onOpenModal
,
EditModal
:
EditTitleModal
}
=
useEditTitle
({
const
{
onOpenModal
,
EditModal
:
EditTitleModal
}
=
useEditTitle
({
...
@@ -173,7 +171,7 @@ const ChatHistorySlider = ({
...
@@ -173,7 +171,7 @@ const ChatHistorySlider = ({
)
}
)
}
</
Flex
>
</
Flex
>
<
Scroll
List
flex=
{
'1 0 0'
}
h=
{
0
}
px=
{
[
2
,
5
]
}
overflow=
{
'overlay'
}
>
<
Scroll
Data
flex=
{
'1 0 0'
}
h=
{
0
}
px=
{
[
2
,
5
]
}
overflow=
{
'overlay'
}
>
{
/* chat history */
}
{
/* chat history */
}
<>
<>
{
concatHistory
.
map
((
item
,
i
)
=>
(
{
concatHistory
.
map
((
item
,
i
)
=>
(
...
@@ -283,7 +281,7 @@ const ChatHistorySlider = ({
...
@@ -283,7 +281,7 @@ const ChatHistorySlider = ({
</
Flex
>
</
Flex
>
))
}
))
}
</>
</>
</
Scroll
List
>
</
Scroll
Data
>
{
/* exec */
}
{
/* exec */
}
{
!
isPc
&&
isUserChatPage
&&
(
{
!
isPc
&&
isUserChatPage
&&
(
...
...
projects/app/src/web/core/chat/context/chatContext.tsx
View file @
e6bad93b
...
@@ -13,7 +13,7 @@ import { ClearHistoriesProps, DelHistoryProps, UpdateHistoryProps } from '@/glob
...
@@ -13,7 +13,7 @@ import { ClearHistoriesProps, DelHistoryProps, UpdateHistoryProps } from '@/glob
import
{
BoxProps
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
{
BoxProps
,
useDisclosure
}
from
'@chakra-ui/react'
;
import
{
useChatStore
}
from
'./storeChat'
;
import
{
useChatStore
}
from
'./storeChat'
;
import
{
getNanoid
}
from
'@fastgpt/global/common/string/tools'
;
import
{
getNanoid
}
from
'@fastgpt/global/common/string/tools'
;
import
{
use
Virtual
ScrollPagination
}
from
'@fastgpt/web/hooks/useScrollPagination'
;
import
{
useScrollPagination
}
from
'@fastgpt/web/hooks/useScrollPagination'
;
type
ChatContextValueType
=
{
type
ChatContextValueType
=
{
params
:
Record
<
string
,
string
|
number
>
;
params
:
Record
<
string
,
string
|
number
>
;
...
@@ -30,7 +30,7 @@ type ChatContextType = {
...
@@ -30,7 +30,7 @@ type ChatContextType = {
forbidLoadChat
:
React
.
MutableRefObject
<
boolean
>
;
forbidLoadChat
:
React
.
MutableRefObject
<
boolean
>
;
onChangeChatId
:
(
chatId
?:
string
,
forbid
?:
boolean
)
=>
void
;
onChangeChatId
:
(
chatId
?:
string
,
forbid
?:
boolean
)
=>
void
;
loadHistories
:
()
=>
void
;
loadHistories
:
()
=>
void
;
Scroll
List
:
({
Scroll
Data
:
({
children
,
children
,
EmptyChildren
,
EmptyChildren
,
isLoading
,
isLoading
,
...
@@ -42,10 +42,6 @@ type ChatContextType = {
...
@@ -42,10 +42,6 @@ type ChatContextType = {
}
&
BoxProps
)
=>
ReactNode
;
}
&
BoxProps
)
=>
ReactNode
;
onChangeAppId
:
(
appId
:
string
)
=>
void
;
onChangeAppId
:
(
appId
:
string
)
=>
void
;
isLoading
:
boolean
;
isLoading
:
boolean
;
historyList
:
{
index
:
number
;
data
:
ChatHistoryItemType
;
}[];
histories
:
ChatHistoryItemType
[];
histories
:
ChatHistoryItemType
[];
onUpdateHistoryTitle
:
({
chatId
,
newTitle
}:
{
chatId
:
string
;
newTitle
:
string
})
=>
void
;
onUpdateHistoryTitle
:
({
chatId
,
newTitle
}:
{
chatId
:
string
;
newTitle
:
string
})
=>
void
;
};
};
...
@@ -53,12 +49,11 @@ type ChatContextType = {
...
@@ -53,12 +49,11 @@ type ChatContextType = {
export
const
ChatContext
=
createContext
<
ChatContextType
>
({
export
const
ChatContext
=
createContext
<
ChatContextType
>
({
chatId
:
''
,
chatId
:
''
,
// forbidLoadChat: undefined,
// forbidLoadChat: undefined,
historyList
:
[],
histories
:
[],
histories
:
[],
onUpdateHistoryTitle
:
function
():
void
{
onUpdateHistoryTitle
:
function
():
void
{
throw
new
Error
(
'Function not implemented.'
);
throw
new
Error
(
'Function not implemented.'
);
},
},
Scroll
List
:
function
():
ReactNode
{
Scroll
Data
:
function
():
ReactNode
{
throw
new
Error
(
'Function not implemented.'
);
throw
new
Error
(
'Function not implemented.'
);
},
},
loadHistories
:
function
():
void
{
loadHistories
:
function
():
void
{
...
@@ -105,17 +100,14 @@ const ChatContextProvider = ({
...
@@ -105,17 +100,14 @@ const ChatContextProvider = ({
const
{
isOpen
:
isOpenSlider
,
onClose
:
onCloseSlider
,
onOpen
:
onOpenSlider
}
=
useDisclosure
();
const
{
isOpen
:
isOpenSlider
,
onClose
:
onCloseSlider
,
onOpen
:
onOpenSlider
}
=
useDisclosure
();
const
{
const
{
scrollDataList
:
historyList
,
ScrollData
,
ScrollList
,
isLoading
:
isPaginationLoading
,
isLoading
:
isPaginationLoading
,
setData
:
setHistories
,
setData
:
setHistories
,
fetchData
:
loadHistories
,
fetchData
:
loadHistories
,
totalData
:
histories
data
:
histories
}
=
useVirtualScrollPagination
(
getChatHistories
,
{
}
=
useScrollPagination
(
getChatHistories
,
{
overscan
:
30
,
pageSize
:
20
,
pageSize
:
30
,
params
,
itemHeight
:
52
,
defaultParams
:
params
,
refreshDeps
:
[
params
]
refreshDeps
:
[
params
]
});
});
...
@@ -229,9 +221,8 @@ const ChatContextProvider = ({
...
@@ -229,9 +221,8 @@ const ChatContextProvider = ({
onChangeChatId
,
onChangeChatId
,
onChangeAppId
,
onChangeAppId
,
isLoading
,
isLoading
,
historyList
,
setHistories
,
setHistories
,
Scroll
List
,
Scroll
Data
,
loadHistories
,
loadHistories
,
histories
,
histories
,
onUpdateHistoryTitle
onUpdateHistoryTitle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment