mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 04:31:27 +08:00
fix(useSessions): correct session fetching logic to use API call
Previously the getSession hook was only searching local data. Now it properly fetches from the API and updates the cache. This ensures data consistency when sessions are modified elsewhere.
This commit is contained in:
parent
77df6fd58e
commit
4c4039283f
@ -30,9 +30,11 @@ export const useSessions = (agent: AgentEntity) => {
|
||||
// TODO: including messages field
|
||||
const getSession = useCallback(
|
||||
async (id: string) => {
|
||||
return data?.find((session) => session.id === id)
|
||||
const result = await client.getSession(agent.id, id)
|
||||
mutate((prev) => prev?.map((session) => (session.id === result.id ? result : session)))
|
||||
return result
|
||||
},
|
||||
[data]
|
||||
[agent.id, client, mutate]
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user