@@ -664,43 +664,6 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
664664 return doSetLoggedIn ( Object . assign ( { } , credentials , { pickleKey } ) , true , true ) ;
665665}
666666
667- /**
668- * Hydrates an existing session by using the credentials provided. This will
669- * not clear any local storage, unlike setLoggedIn().
670- *
671- * Stops the existing Matrix client (without clearing its data) and starts a
672- * new one in its place. This additionally starts all other react-sdk services
673- * which use the new Matrix client.
674- *
675- * If the credentials belong to a different user from the session already stored,
676- * the old session will be cleared automatically.
677- *
678- * @param {IMatrixClientCreds } credentials The credentials to use
679- *
680- * @returns {Promise } promise which resolves to the new MatrixClient once it has been started
681- */
682- export async function hydrateSession ( credentials : IMatrixClientCreds ) : Promise < MatrixClient > {
683- const oldUserId = MatrixClientPeg . safeGet ( ) . getUserId ( ) ;
684- const oldDeviceId = MatrixClientPeg . safeGet ( ) . getDeviceId ( ) ;
685-
686- stopMatrixClient ( ) ; // unsets MatrixClientPeg.get()
687- localStorage . removeItem ( "mx_soft_logout" ) ;
688- _isLoggingOut = false ;
689-
690- const overwrite = credentials . userId !== oldUserId || credentials . deviceId !== oldDeviceId ;
691- if ( overwrite ) {
692- logger . warn ( "Clearing all data: Old session belongs to a different user/session" ) ;
693- }
694-
695- if ( ! credentials . pickleKey && credentials . deviceId !== undefined ) {
696- logger . info ( "Lifecycle#hydrateSession: Pickle key not provided - trying to get one" ) ;
697- credentials . pickleKey =
698- ( await PlatformPeg . get ( ) ?. getPickleKey ( credentials . userId , credentials . deviceId ) ) ?? undefined ;
699- }
700-
701- return doSetLoggedIn ( credentials , overwrite , false ) ;
702- }
703-
704667/**
705668 * When we have a authenticated via OIDC-native flow and have a refresh token
706669 * try to create a token refresher.
@@ -799,18 +762,6 @@ async function doSetLoggedIn(
799762 PosthogAnalytics . instance . startListeningToSettingsChanges ( client ) ;
800763 }
801764
802- if ( credentials . freshLogin && SettingsStore . getValue ( "feature_dehydration" ) ) {
803- // If we just logged in, try to rehydrate a device instead of using a
804- // new device. If it succeeds, we'll get a new device ID, so make sure
805- // we persist that ID to localStorage
806- const newDeviceId = await client . rehydrateDevice ( ) ;
807- if ( newDeviceId ) {
808- credentials . deviceId = newDeviceId ;
809- }
810-
811- delete credentials . freshLogin ;
812- }
813-
814765 if ( localStorage ) {
815766 try {
816767 await persistCredentials ( credentials ) ;
0 commit comments