importDump method

Future<bool> importDump(
  1. String export
)

imports a dumped session

WARNING: never re-import the dump twice

Implementation

Future<bool> importDump(String export) async {
  try {
    // stopping sync loop and subscriptions while keeping DB open
    await dispose(closeDatabase: false);
  } catch (_) {
    // Client was probably not initialized yet.
  }

  _database ??= await databaseBuilder!.call(this);

  final success = await database!.importDump(export);

  if (success) {
    // closing including DB
    await dispose();

    try {
      bearerToken = null;

      await init(
        waitForFirstSync: false,
        waitUntilLoadCompletedLoaded: false,
      );
    } catch (e) {
      return false;
    }
  }
  return success;
}