loadSingleKey method

Future<void> loadSingleKey(
  1. String roomId,
  2. String sessionId
)

Loads a single key for the specified room from the online key backup and stores it.

Implementation

Future<void> loadSingleKey(String roomId, String sessionId) async {
  final info = await getRoomKeysBackupInfo();
  late KeyBackupData ret;
  try {
    ret = await client.getRoomKeyBySessionId(roomId, sessionId, info.version);
  } on MatrixException catch (e) {
    final retryAfterMs = e.retryAfterMs;
    if (retryAfterMs == null) rethrow;
    await Future.delayed(Duration(milliseconds: retryAfterMs));
    ret = await client.getRoomKeyBySessionId(roomId, sessionId, info.version);
  }
  final keys = RoomKeys.fromJson({
    'rooms': {
      roomId: {
        'sessions': {sessionId: ret.toJson()},
      },
    },
  });
  await loadFromResponse(keys);
}