init(serializedAppStateStr) {
      if (serializedAppStateStr) {
        try {
          const state = JSON.parse(serializedAppStateStr);
          if (!!state &&
              state[print_preview.AppStateField.VERSION] == AppState.VERSION_) {
            this.state_ = /** @type {!Object} */ (state);
          }
        } catch (e) {
          console.error('Unable to parse state: ' + e);
          // Proceed with default state.
        }
      } else {
        // Set some state defaults.
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      }
      if (!this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]) {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      } else if (!(this.state_[print_preview.AppStateField
                                   .RECENT_DESTINATIONS] instanceof
                   Array)) {
        const tmp =
            this.state_[print_preview.AppStateField.RECENT_DESTINATIONS];
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [tmp];
      } else if (
          !this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0] ||
          !this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0].id) {
        // read in incorrectly
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      } else if (
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length >
          AppState.NUM_DESTINATIONS_) {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length =
            AppState.NUM_DESTINATIONS_;
      }
    }
/**
     * Initializes the app state from a serialized string returned by the native
     * layer.
     * @param {?string} serializedAppStateStr Serialized string representation
     *     of the app state.
     */
Initializes the app state from a serialized string returned by the native
layer.
@param {?string} serializedAppStateStr Serialized string representation
of the app state.
Initializes the app state from a serialized string returned by the native layer . @param { ?string } serializedAppStateStr Serialized string representation of the app state .
init(serializedAppStateStr) {
      if (serializedAppStateStr) {
        try {
          const state = JSON.parse(serializedAppStateStr);
          if (!!state &&
              state[print_preview.AppStateField.VERSION] == AppState.VERSION_) {
            this.state_ =  (state);
          }
        } catch (e) {
          console.error('Unable to parse state: ' + e);
        }
      } else {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      }
      if (!this.state_[print_preview.AppStateField.RECENT_DESTINATIONS]) {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      } else if (!(this.state_[print_preview.AppStateField
                                   .RECENT_DESTINATIONS] instanceof
                   Array)) {
        const tmp =
            this.state_[print_preview.AppStateField.RECENT_DESTINATIONS];
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [tmp];
      } else if (
          !this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0] ||
          !this.state_[print_preview.AppStateField.RECENT_DESTINATIONS][0].id) {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS] = [];
      } else if (
          this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length >
          AppState.NUM_DESTINATIONS_) {
        this.state_[print_preview.AppStateField.RECENT_DESTINATIONS].length =
            AppState.NUM_DESTINATIONS_;
      }
    }
init ( serializedAppStateStr ) { if ( serializedAppStateStr ) { try { const state = JSON . parse ( serializedAppStateStr ) ; if ( ! ! state && state [ print_preview . AppStateField . VERSION ] == AppState . VERSION_ ) { this . state_ = ( state ) ; } } catch ( e ) { console . error ( 'Unable to parse state: ' + e ) ; } } else { this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] = [ ] ; } if ( ! this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] ) { this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] = [ ] ; } else if ( ! ( this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] instanceof Array ) ) { const tmp = this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] ; this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] = [ tmp ] ; } else if ( ! this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] [ 0 ] || ! this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] [ 0 ] . id ) { this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] = [ ] ; } else if ( this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . length > AppState . NUM_DESTINATIONS_ ) { this . state_ [ print_preview . AppStateField . RECENT_DESTINATIONS ] . length = AppState . NUM_DESTINATIONS_ ; } }
Initializes the app state from a serialized string returned by the native
 layer.
Initializes the app state from a serialized string returned by the native layer .
/** @type {!Object} */ // Proceed with default state. // Set some state defaults. // read in incorrectly