handlePresentationCurrent method

void handlePresentationCurrent(
  1. Map data
)

Implementation

void handlePresentationCurrent(Map<dynamic, dynamic> data) {
  // the 'presentation' field never contains the path
  var p = ProPresentation.fromMap(this, data['presentation']);

  // if presentationPath is set, then we have received a `presentationCurrent` response
  // otherwise, we have received a `presentationRequest` response
  if (data.containsKey('presentationPath')) {
    // this was a response to a `presentationCurrent` request
    // the setter will merge with seen presentations if needed
    p.presentationPath = data['presentationPath'];
    state.currentPresentation = p;
  } else {
    // this was a response to a 'presentationRequest' request
    // meaning that we requested it with a path and should have stored that
    if (requestedPresentationPath != null) {
      p.presentationPath = requestedPresentationPath!;
      if (state.presentationsByPath.containsKey(requestedPresentationPath)) {
        state.presentationsByPath[requestedPresentationPath]!.mergePresentation(p);
      } else {
        state.presentationsByPath[requestedPresentationPath!] = p;
      }

      // ProPresenter always returns the location of the current presentation too
      // but it is buried in the 'presentation' response
      var currentPresentationPath = data['presentation']['presentationCurrentLocation'];
      var cp = state.presentationsByPath[currentPresentationPath];
      if (cp != null) {
        state.currentPresentation = cp;
      }
      loading = false;
    }
  }

  // Pro6 sometimes (like with trigger commands) sends only the basename as a partial path
  // so we store a mapping from this basename to the full path
  basename2fullpath[basename(p.presentationPath)] = p.presentationPath;
  _slideUpdatesStreamController.add(true);
  emit('presentation');
  notify();
}