persistSelectedDestination_() {
      assert(this.isInitialized_);

      const destination = this.destinationStore_.selectedDestination;
      if (!destination)
        return;

      // Determine if this destination is already in the recent destinations,
      // and where in the array it is located.
      const newDestination =
          print_preview.makeRecentDestination(assert(destination));
      let indexFound =
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]
              .findIndex(function(recent) {
                return (
                    newDestination.id == recent.id &&
                    newDestination.origin == recent.origin);
              });

      // No change
      if (indexFound == 0 &&
          this.selectedDestination.capabilities ==
              newDestination.capabilities) {
        this.persist_();
        return;
      }

      // Shift the array so that the nth most recent destination is located at
      // index n.
      if (indexFound == -1 &&
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length ==
              AppState.NUM_DESTINATIONS_) {
        indexFound = AppState.NUM_DESTINATIONS_ - 1;
      }
      if (indexFound != -1)
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
            indexFound, 1);

      // Add the most recent destination
      this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
          0, 0, newDestination);

      this.persist_();
    }
/**
     * Persists the selected destination from the destination store.
     * @private
     */
Persists the selected destination from the destination store.
@private
Persists the selected destination from the destination store . @private
persistSelectedDestination_() {
      assert(this.isInitialized_);
      const destination = this.destinationStore_.selectedDestination;
      if (!destination)
        return;
      const newDestination =
          print_preview.makeRecentDestination(assert(destination));
      let indexFound =
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]
              .findIndex(function(recent) {
                return (
                    newDestination.id == recent.id &&
                    newDestination.origin == recent.origin);
              });
      if (indexFound == 0 &&
          this.selectedDestination.capabilities ==
              newDestination.capabilities) {
        this.persist_();
        return;
      }
      if (indexFound == -1 &&
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length ==
              AppState.NUM_DESTINATIONS_) {
        indexFound = AppState.NUM_DESTINATIONS_ - 1;
      }
      if (indexFound != -1)
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
            indexFound, 1);
      this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].splice(
          0, 0, newDestination);
      this.persist_();
    }
persistSelectedDestination_ ( ) { assert ( this . isInitialized_ ) ; const destination = this . destinationStore_ . selectedDestination ; if ( ! destination ) return ; const newDestination = print_preview . makeRecentDestination ( assert ( destination ) ) ; let indexFound = this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . findIndex ( function ( recent ) { return ( newDestination . id == recent . id && newDestination . origin == recent . origin ) ; } ) ; if ( indexFound == 0 && this . selectedDestination . capabilities == newDestination . capabilities ) { this . persist_ ( ) ; return ; } if ( indexFound == - 1 && this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . length == AppState . NUM_DESTINATIONS_ ) { indexFound = AppState . NUM_DESTINATIONS_ - 1 ; } if ( indexFound != - 1 ) this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . splice ( indexFound , 1 ) ; this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . splice ( 0 , 0 , newDestination ) ; this . persist_ ( ) ; }
Persists the selected destination from the destination store.
Persists the selected destination from the destination store .
// Determine if this destination is already in the recent destinations, // and where in the array it is located. // No change // Shift the array so that the nth most recent destination is located at // index n. // Add the most recent destination