@@ -7,34 +7,12 @@ Please see LICENSE files in the repository root for full details.
77*/
88
99import { logger } from "matrix-js-sdk/src/logger" ;
10- import { type CryptoApi , type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api" ;
10+ import { type StartDehydrationOpts } from "matrix-js-sdk/src/crypto-api" ;
1111
1212import type { MatrixClient } from "matrix-js-sdk/src/matrix" ;
1313
1414/**
15- * Check if device dehydration is enabled.
16- *
17- * Note that this doesn't necessarily mean that device dehydration has been initialised
18- * (yet) on this client; rather, it means that the server supports it, the crypto backend
19- * supports it, and the application configuration suggests that it *should* be
20- * initialised on this device.
21- *
22- * Dehydration can currently only be enabled by setting a flag in the .well-known file.
23- */
24- async function deviceDehydrationEnabled ( client : MatrixClient , crypto : CryptoApi | undefined ) : Promise < boolean > {
25- if ( ! crypto ) {
26- return false ;
27- }
28- if ( ! ( await crypto . isDehydrationSupported ( ) ) ) {
29- return false ;
30- }
31- const wellknown = await client . waitForClientWellKnown ( ) ;
32- return ! ! wellknown ?. [ "org.matrix.msc3814" ] ;
33- }
34-
35- /**
36- * If dehydration is enabled (i.e., it is supported by the server and enabled in
37- * the configuration), rehydrate a device (if available) and create
15+ * If dehydration is supported by the server, rehydrate a device (if available) and create
3816 * a new dehydrated device.
3917 *
4018 * @param client - MatrixClient to use for the operation
@@ -45,8 +23,8 @@ export async function initialiseDehydrationIfEnabled(
4523 opts : StartDehydrationOpts = { } ,
4624) : Promise < void > {
4725 const crypto = client . getCrypto ( ) ;
48- if ( await deviceDehydrationEnabled ( client , crypto ) ) {
49- logger . log ( "Device dehydration enabled ") ;
50- await crypto ! . startDehydration ( opts ) ;
26+ if ( crypto && ( await crypto . isDehydrationSupported ( ) ) ) {
27+ logger . debug ( "Starting device dehydration ") ;
28+ await crypto . startDehydration ( opts ) ;
5129 }
5230}
0 commit comments