Paratii-Video / paratii-portal

Component-based web-interface for uploading, browsing and organising content of Paratii's P2P network.
GNU General Public License v3.0
12 stars 5 forks source link

Update ProrgrDuplication code #159

Closed eliawk closed 6 years ago

eliawk commented 6 years ago

This code is in VideoForm.js and in VideoListItem.js.

const video = nextProps.selectedVideo

    if (video.getIn(['uploadStatus', 'name']) === 'running') {
      const progress = video.getIn(['uploadStatus', 'data', 'progress'])
      this.setState({ uploadProgress: progress })
    } else if (
      video.getIn(['uploadStatus', 'name']) === 'uploaded to transcoder node'
    ) {
      this.setState({ uploadProgress: 100 })
    }

    if (video.getIn(['transcodingStatus', 'name']) === 'progress') {
      const progress = video.getIn(['transcodingStatus', 'data', 'progress'])
      this.setState({ transcodingProgress: progress })
    } else if (video.getIn(['transcodingStatus', 'name']) === 'success') {
      this.setState({ transcodingProgress: 100 })
    }

    this.setState({
      totalProgress: Math.round(
        (this.state.uploadProgress + this.state.transcodingProgress) / 2
      )
    })

i think we need to write it just once and reuse it. Also in VideoListItem.js there is some issue on the update cycle, it doesn't always dipaly the correct value.

jellegerbrandy commented 6 years ago

I don't now why we use a state in the videolist item. Isn't that just a thing we use for tracking the state of the form? If I'm right, then we can just read the info for rendering video-list-item from the props directly, right?

bent0b0x commented 6 years ago

In general @jellegerbrandy I think you are right. And when we need to get calculated pieces of state from our store (uploadProgress may be an example), then we should use a selector

eliawk commented 6 years ago

@jelle we need some logic, becasue the progress could be in progress or ended ( = 100%). but the selector is the answer to my problem instead of local stage