open method

Future<void> open()

Implementation

Future<void> open() async {
  _clientBox = await Hive.openBox(
    _clientBoxName,
    encryptionCipher: encryptionCipher,
  );
  _accountDataBox = await Hive.openBox(
    _accountDataBoxName,
    encryptionCipher: encryptionCipher,
  );
  _roomsBox = await Hive.openBox(
    _roomsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _roomStateBox = await Hive.openLazyBox(
    _roomStateBoxName,
    encryptionCipher: encryptionCipher,
  );
  _roomMembersBox = await Hive.openLazyBox(
    _roomMembersBoxName,
    encryptionCipher: encryptionCipher,
  );
  _toDeviceQueueBox = await Hive.openBox(
    _toDeviceQueueBoxName,
    encryptionCipher: encryptionCipher,
  );
  _roomAccountDataBox = await Hive.openLazyBox(
    _roomAccountDataBoxName,
    encryptionCipher: encryptionCipher,
  );
  _inboundGroupSessionsBox = await Hive.openLazyBox(
    _inboundGroupSessionsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _outboundGroupSessionsBox = await Hive.openLazyBox(
    _outboundGroupSessionsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _olmSessionsBox = await Hive.openLazyBox(
    _olmSessionsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _userDeviceKeysBox = await Hive.openLazyBox(
    _userDeviceKeysBoxName,
    encryptionCipher: encryptionCipher,
  );
  _userDeviceKeysOutdatedBox = await Hive.openLazyBox(
    _userDeviceKeysOutdatedBoxName,
    encryptionCipher: encryptionCipher,
  );
  _userCrossSigningKeysBox = await Hive.openLazyBox(
    _userCrossSigningKeysBoxName,
    encryptionCipher: encryptionCipher,
  );
  _ssssCacheBox = await Hive.openLazyBox(
    _ssssCacheBoxName,
    encryptionCipher: encryptionCipher,
  );
  _presencesBox = await Hive.openLazyBox(
    _presencesBoxName,
    encryptionCipher: encryptionCipher,
  );
  _timelineFragmentsBox = await Hive.openLazyBox(
    _timelineFragmentsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _eventsBox = await Hive.openLazyBox(
    _eventsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _seenDeviceIdsBox = await Hive.openLazyBox(
    _seenDeviceIdsBoxName,
    encryptionCipher: encryptionCipher,
  );
  _seenDeviceKeysBox = await Hive.openLazyBox(
    _seenDeviceKeysBoxName,
    encryptionCipher: encryptionCipher,
  );

  // Check version and check if we need a migration
  final currentVersion = (await _clientBox.get('version') as int?);
  if (currentVersion == null) {
    await _clientBox.put('version', version);
  } else if (currentVersion != version) {
    await _migrateFromVersion(currentVersion);
  }

  return;
}