diff --git a/src/containers/Connections/index.tsx b/src/containers/Connections/index.tsx index c3dc87b..680c19f 100644 --- a/src/containers/Connections/index.tsx +++ b/src/containers/Connections/index.tsx @@ -224,7 +224,7 @@ export default function Connections () { const conn = data.find(c => c.id === drawerState.selectedID)?.original if (conn) { setDrawerState(d => { - d.connection = conn + d.connection = { ...conn } if (drawerState.selectedID === latestConntion.current.id) { d.connection.completed = latestConntion.current.completed } diff --git a/src/containers/Connections/store.ts b/src/containers/Connections/store.ts index 380c9d3..48dc4f1 100644 --- a/src/containers/Connections/store.ts +++ b/src/containers/Connections/store.ts @@ -1,3 +1,4 @@ +import produce from 'immer' import { useState, useMemo, useRef, useCallback } from 'react' import * as API from '@lib/request' @@ -39,9 +40,11 @@ class Store { } else { const connection = this.connections.get(id) if (connection != null) { - connection.completed = true - connection.uploadSpeed = 0 - connection.downloadSpeed = 0 + this.connections.set(id, produce(connection, draft => { + draft.completed = true + draft.uploadSpeed = 0 + draft.downloadSpeed = 0 + })) } } }