restoreSession method

Future<void> restoreSession(
  1. String linkToken
)

Swaps a magic-link token for that session.

Implementation

Future<void> restoreSession(String linkToken) async {
  final r = await _api.restoreSession(linkToken: linkToken);
  _closeSocket();
  _token = r.visitorToken;
  _pushRegisteredFor = null;
  _pushDirty = _stored.pushToken != null;
  await _persist(
    _stored.copyWith(token: r.visitorToken, conversationId: r.conversationId, lastSeq: 0, clearIdentity: true),
  );
  _emit(_state.copyWith(clearConversation: true, timeline: Timeline.empty, pending: const [], unread: 0));
  await _bootstrapAndConnect();
  _event(HatangSessionChanged(visitorId: r.visitorId, reason: HatangSessionChangeReason.restored));
}