@@ -17,7 +17,7 @@ See the License for the specific language governing permissions and
17
17
limitations under the License.
18
18
*/
19
19
20
- import React , { useCallback , useMemo , useState , useEffect , useContext , useRef } from 'react' ;
20
+ import React , { useCallback , useMemo , useState , useEffect , useContext } from 'react' ;
21
21
import PropTypes from 'prop-types' ;
22
22
import classNames from 'classnames' ;
23
23
import { Group , RoomMember , User } from 'matrix-js-sdk' ;
@@ -137,25 +137,18 @@ function useIsEncrypted(cli, room) {
137
137
}
138
138
139
139
function useHasCrossSigningKeys ( cli , member , canVerify , setUpdating ) {
140
- // use a ref to setUpdating because we don't want to rerun
141
- // the useAsyncMemo hook when it changes.
142
- const updatingRef = useRef ( ) ;
143
- useEffect ( ( ) => {
144
- updatingRef . current = setUpdating ;
145
- } , [ setUpdating ] ) ;
146
-
147
140
return useAsyncMemo ( async ( ) => {
148
141
if ( ! canVerify ) {
149
142
return false ;
150
143
}
151
- updatingRef . current ( true ) ;
144
+ setUpdating ( true ) ;
152
145
try {
153
146
await cli . downloadKeys ( [ member . userId ] ) ;
154
147
const xsi = cli . getStoredCrossSigningForUser ( member . userId ) ;
155
148
const key = xsi && xsi . getId ( ) ;
156
149
return ! ! key ;
157
150
} finally {
158
- updatingRef . current ( false ) ;
151
+ setUpdating ( false ) ;
159
152
}
160
153
} , [ cli , member , canVerify ] , false ) ;
161
154
}
@@ -1356,9 +1349,9 @@ const BasicUserInfo = ({room, member, groupId, devices, isRoomEncrypted}) => {
1356
1349
homeserverSupportsCrossSigning &&
1357
1350
isRoomEncrypted && ! userVerified && ! isMe ;
1358
1351
1359
- const setUpdating = useCallback ( ( updating ) => {
1360
- setPendingUpdateCount ( pendingUpdateCount + ( updating ? 1 : - 1 ) ) ;
1361
- } , [ setPendingUpdateCount , pendingUpdateCount ] ) ;
1352
+ const setUpdating = ( updating ) => {
1353
+ setPendingUpdateCount ( count => count + ( updating ? 1 : - 1 ) ) ;
1354
+ } ;
1362
1355
const hasCrossSigningKeys =
1363
1356
useHasCrossSigningKeys ( cli , member , canVerify , setUpdating ) ;
1364
1357
0 commit comments