Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace MatrixClient.isRoomEncrypted by MatrixClient.CryptoApi.isEncryptionEnabledInRoom in useIsEncrypted #28282

Conversation

florianduros
Copy link
Member

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • I have licensed the changes to Element by completing the Contributor License Agreement (CLA)

Task #26922

…ncryptionEnabledInRoom` in `useIsEncrypted`
try {
setIsEncrypted(await cli.getCrypto()?.isEncryptionEnabledInRoom(room.roomId));
} catch {
setIsEncrypted(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if encrypted is true and the room didn't change but isEncryptionEnabledInRoom threw should we really be setting to false? This seems unexpected.

We probably also need to reset to null when room changes whilst func is calling the async function which could take multiple ticks

Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably be also done like this:

const encryptionStateEvent = useRoomState(...);
return useAsyncMemo(() => {...}, [room, encryptionStateEvent]);

@florianduros
Copy link
Member Author

Could probably be also done like this:

const encryptionStateEvent = useRoomState(...);
return useAsyncMemo(() => {...}, [room, encryptionStateEvent]);

Are you suggesting to get the encryption state event with useRoomState(room, (roomState) => roomState.getStateEvents(EventType.RoomEncryption)). Where it should have only one (event)

@t3chguy
Copy link
Member

t3chguy commented Nov 12, 2024

Where it should have only one (event)

Yes but it'll be the dependency for useAsyncMemo so it reacts to state event updates

@florianduros florianduros added this pull request to the merge queue Nov 13, 2024
Merged via the queue into develop with commit 8a756b5 Nov 13, 2024
34 checks passed
@florianduros florianduros deleted the florianduros/rip-out-legacy-crypto/migrate-useIsEncryped-isroomencrypted branch November 13, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Task Tasks for the team like planning
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants