1
1
import { useMessages } from '@/hooks/useMessages'
2
2
import { useModelProvider } from '@/hooks/useModelProvider'
3
- import { useThreads } from '@/hooks/useThreads'
3
+
4
4
import { useAppUpdater } from '@/hooks/useAppUpdater'
5
5
import { fetchMessages } from '@/services/messages'
6
6
import { fetchModels } from '@/services/models'
@@ -15,7 +15,7 @@ import { getAssistants } from '@/services/assistants'
15
15
16
16
export function DataProvider ( ) {
17
17
const { setProviders } = useModelProvider ( )
18
- const { setThreads } = useThreads ( )
18
+
19
19
const { setMessages } = useMessages ( )
20
20
const { checkForUpdate } = useAppUpdater ( )
21
21
const { setServers } = useMCPServers ( )
@@ -35,26 +35,6 @@ export function DataProvider() {
35
35
36
36
useEffect ( ( ) => {
37
37
fetchThreads ( ) . then ( ( threads ) => {
38
- // Sort threads by order if available, otherwise by updated time
39
- const sortedThreads = threads . sort ( ( a , b ) => {
40
- // If both have order, sort by order
41
- if ( a . order != null && b . order != null ) {
42
- return a . order - b . order
43
- }
44
- // If only one has order, prioritize the one with order
45
- if ( a . order != null ) return - 1
46
- if ( b . order != null ) return 1
47
- // If neither has order, sort by updated time (newest first)
48
- return ( b . updated || 0 ) - ( a . updated || 0 )
49
- } )
50
-
51
- // Assign orders to threads that don't have them to ensure future drag operations work
52
- const threadsWithOrder = sortedThreads . map ( ( thread , index ) => ( {
53
- ...thread ,
54
- order : thread . order ?? index + 1 ,
55
- } ) )
56
-
57
- setThreads ( threadsWithOrder )
58
38
threads . forEach ( ( thread ) =>
59
39
fetchMessages ( thread . id ) . then ( ( messages ) =>
60
40
setMessages ( thread . id , messages )
0 commit comments