static/js/Main.js
/**
     * Contacts server and loads new images
     */
Contacts server and loads new images
Contacts server and loads new images
fetchImages(callback){
        console.log("Sending update command");
        this.setLoading(true);
        fetch("/actions/update")
          .then(() => {
            fetch("/channels")
              .then(response => response.json())
              .then(
                (data) => {
                  console.log("Reading Channels");
                  this.channels = data.filter(
                    channel => channel.latest
                  );
                  console.log(data);
                  if(this.channels.length > 0){
                    this.setLoading(false);
                    this.setError(false);
                  }
                  if(callback){
                    callback();
                  }
                }
              )
          }
        )
        .catch(error => {
            this.setError(true);
            console.log("Unable to do update command");
        });
    }
fetchImages ( callback ) { console . log ( "Sending update command" ) ; this . setLoading ( true ) ; fetch ( "/actions/update" ) . then ( ( ) => { fetch ( "/channels" ) . then ( response => response . json ( ) ) . then ( ( data ) => { console . log ( "Reading Channels" ) ; this . channels = data . filter ( channel => channel . latest ) ; console . log ( data ) ; if ( this . channels . length > 0 ) { this . setLoading ( false ) ; this . setError ( false ) ; } if ( callback ) { callback ( ) ; } } ) } ) . catch ( error => { this . setError ( true ) ; console . log ( "Unable to do update command" ) ; } ) ; }
Contacts server and loads new images
Contacts server and loads new images
// Skip channels that don't have images.