constructor()

in js/tabs/schedule/SessionsCarousel.js [68:112]


  constructor(props: Props) {
    super(props);

    const flatSessionsList = [];
    const contexts: Array<Context> = [];
    let allSessions = this.props.allSessions;
    if (!allSessions) {
      const { session } = this.props;
      allSessions = {
        [formatTime(session.startTime)]: { [session.id]: session }
      };
    }

    // TODO: Add test
    for (let sectionID in allSessions) {
      const sectionLength = Object.keys(allSessions[sectionID]).length;
      let rowIndex = 0;
      for (let sessionID in allSessions[sectionID]) {
        const session = allSessions[sectionID][sessionID];
        flatSessionsList.push(session);
        contexts.push({
          rowIndex,
          sectionLength,
          sectionTitle: sectionID
        });
        rowIndex++;
      }
    }

    const selectedIndex = flatSessionsList.findIndex(
      s => s.id === this.props.session.id
    );

    this.state = {
      day: this.props.session.day,
      count: flatSessionsList.length,
      selectedIndex,
      flatSessionsList,
      contexts
    };
    (this: any).dismiss = this.dismiss.bind(this);
    (this: any).handleIndexChange = this.handleIndexChange.bind(this);
    (this: any).renderCard = this.renderCard.bind(this);
    (this: any).shareCurrentSession = this.shareCurrentSession.bind(this);
  }