getCall static method

WebStoredCall? getCall(
  1. ChatId chatId
)

Returns a call identified by the provided chatId from the browser's storage.

Implementation

static WebStoredCall? getCall(ChatId chatId) {
  final data = web.window.localStorage.getItem('call_$chatId');
  if (data != null) {
    final at = web.window.localStorage.getItem('at_call_$chatId');
    final updatedAt = at == null ? DateTime.now() : DateTime.parse(at);
    if (DateTime.now().difference(updatedAt).inSeconds <= 1) {
      return WebStoredCall.fromJson(json.decode(data));
    }
  }

  return null;
}