Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
28b793f7
Commit
28b793f7
authored
Jun 28, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: update conversation flash
parent
998f819b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
index.tsx
web/app/components/share/chat/index.tsx
+22
-4
index.tsx
web/app/components/share/chat/sidebar/index.tsx
+6
-0
index.tsx
web/app/components/share/chat/sidebar/list/index.tsx
+3
-1
No files found.
web/app/components/share/chat/index.tsx
View file @
28b793f7
...
...
@@ -67,6 +67,8 @@ const Main: FC<IMainProps> = ({
* conversation info
*/
const
[
allConversationList
,
setAllConversationList
]
=
useState
<
ConversationItem
[]
>
([])
const
[
isClearConversationList
,
{
setTrue
:
clearConversationListTrue
,
setFalse
:
clearConversationListFalse
}]
=
useBoolean
(
false
)
const
[
isClearPinnedConversationList
,
{
setTrue
:
clearPinnedConversationListTrue
,
setFalse
:
clearPinnedConversationListFalse
}]
=
useBoolean
(
false
)
const
{
conversationList
,
setConversationList
,
...
...
@@ -89,18 +91,32 @@ const Main: FC<IMainProps> = ({
const
[
hasPinnedMore
,
setHasPinnedMore
]
=
useState
<
boolean
>
(
true
)
const
onMoreLoaded
=
({
data
:
conversations
,
has_more
}:
any
)
=>
{
setHasMore
(
has_more
)
setConversationList
([...
conversationList
,
...
conversations
])
if
(
isClearConversationList
)
{
setConversationList
(
conversations
)
clearConversationListFalse
()
}
else
{
setConversationList
([...
conversationList
,
...
conversations
])
}
}
const
onPinnedMoreLoaded
=
({
data
:
conversations
,
has_more
}:
any
)
=>
{
setHasPinnedMore
(
has_more
)
setPinnedConversationList
([...
pinnedConversationList
,
...
conversations
])
if
(
isClearPinnedConversationList
)
{
setPinnedConversationList
(
conversations
)
clearPinnedConversationListFalse
()
}
else
{
setPinnedConversationList
([...
pinnedConversationList
,
...
conversations
])
}
}
const
[
controlUpdateConversationList
,
setControlUpdateConversationList
]
=
useState
(
0
)
const
noticeUpdateList
=
()
=>
{
setConversationList
([])
setHasMore
(
true
)
setPinnedConversationList
([])
clearConversationListTrue
()
setHasPinnedMore
(
true
)
clearPinnedConversationListTrue
()
setControlUpdateConversationList
(
Date
.
now
())
}
const
handlePin
=
async
(
id
:
string
)
=>
{
...
...
@@ -496,7 +512,9 @@ const Main: FC<IMainProps> = ({
return
(
<
Sidebar
list=
{
conversationList
}
isClearConversationList=
{
isClearConversationList
}
pinnedList=
{
pinnedConversationList
}
isClearPinnedConversationList=
{
isClearPinnedConversationList
}
onMoreLoaded=
{
onMoreLoaded
}
onPinnedMoreLoaded=
{
onPinnedMoreLoaded
}
isNoMore=
{
!
hasMore
}
...
...
web/app/components/share/chat/sidebar/index.tsx
View file @
28b793f7
...
...
@@ -17,7 +17,9 @@ export type ISidebarProps = {
currentId
:
string
onCurrentIdChange
:
(
id
:
string
)
=>
void
list
:
ConversationItem
[]
isClearConversationList
:
boolean
pinnedList
:
ConversationItem
[]
isClearPinnedConversationList
:
boolean
isInstalledApp
:
boolean
installedAppId
?:
string
siteInfo
:
SiteInfo
...
...
@@ -36,7 +38,9 @@ const Sidebar: FC<ISidebarProps> = ({
currentId
,
onCurrentIdChange
,
list
,
isClearConversationList
,
pinnedList
,
isClearPinnedConversationList
,
isInstalledApp
,
installedAppId
,
siteInfo
,
...
...
@@ -102,6 +106,7 @@ const Sidebar: FC<ISidebarProps> = ({
currentId=
{
currentId
}
onCurrentIdChange=
{
onCurrentIdChange
}
list=
{
pinnedList
}
isClearConversationList=
{
isClearPinnedConversationList
}
isInstalledApp=
{
isInstalledApp
}
installedAppId=
{
installedAppId
}
onMoreLoaded=
{
onPinnedMoreLoaded
}
...
...
@@ -123,6 +128,7 @@ const Sidebar: FC<ISidebarProps> = ({
currentId=
{
currentId
}
onCurrentIdChange=
{
onCurrentIdChange
}
list=
{
list
}
isClearConversationList=
{
isClearConversationList
}
isInstalledApp=
{
isInstalledApp
}
installedAppId=
{
installedAppId
}
onMoreLoaded=
{
onMoreLoaded
}
...
...
web/app/components/share/chat/sidebar/list/index.tsx
View file @
28b793f7
...
...
@@ -17,6 +17,7 @@ export type IListProps = {
currentId
:
string
onCurrentIdChange
:
(
id
:
string
)
=>
void
list
:
ConversationItem
[]
isClearConversationList
:
boolean
isInstalledApp
:
boolean
installedAppId
?:
string
onMoreLoaded
:
(
res
:
{
data
:
ConversationItem
[];
has_more
:
boolean
})
=>
void
...
...
@@ -32,6 +33,7 @@ const List: FC<IListProps> = ({
currentId
,
onCurrentIdChange
,
list
,
isClearConversationList
,
isInstalledApp
,
installedAppId
,
onMoreLoaded
,
...
...
@@ -46,7 +48,7 @@ const List: FC<IListProps> = ({
useInfiniteScroll
(
async
()
=>
{
if
(
!
isNoMore
)
{
const
lastId
=
list
[
list
.
length
-
1
]?.
i
d
const
lastId
=
!
isClearConversationList
?
list
[
list
.
length
-
1
]?.
id
:
undefine
d
const
{
data
:
conversations
,
has_more
}:
any
=
await
fetchConversations
(
isInstalledApp
,
installedAppId
,
lastId
,
isPinned
)
onMoreLoaded
({
data
:
conversations
,
has_more
})
}
...
...
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