How to disable or cancel Refresher and infiniteScroll when there is no connection


#1

Hi , I have a component where it list set of items, it also includes a refresher and infinite scroll… I am also watching for connection availability, I am presenting a toast when ever there is a connection or not… but I do not know how to handle the refresher and infinite scroll when there is not connection available, when the user pulls down for refresh , the apps gets stuck there becuz there is no connection in order for it to complete

.ts

    constructor(...........................) {   ///// I am watching connection availability in constructor
        platform.ready().then((readySource => {
        this.watchforConnection();
        this.watchforDisconnect();

        let disconnect = this.watchforDisconnect();
            disconnect.unsubscribe();

        let connected = this.watchforConnection();
            connected.unsubscribe();
        }));
    }


   ionViewWillLoad(){
       this.jobsData.load().subscribe(
          (res) => {
              this.jobs = res;        ////// assigning the list items
              this.local.localData(res)    ////// storing in Storage to be cached 
              loading.dismiss();         ///// dismissing loading (since there is loading when the user enters the page)
          },
          (err) => {
              loading.dismiss();
              let toast = this.loadingOffline();  ///// handling error by showing a toast 

              toast.onWillDismiss(() => {
               this.local.getLocalData().then((res) => {   ///// when toast is dismissed , loading from cached data
                this.jobs = res;
                })
              });    
          });

            let loading = this.presentLoadingCustom();  ///// custom loader when the user enters the page
     }

     doRefresh(refresh){
         setTimeout(() => {
             this.jobsData.load().subscribe(res => {
             this.updatedJobs = res;    ///// assigning the updated list

           if (this.jobs[0].id === this.updatedJobs[0].id){   ///// checking whether the list actually updated
             this.presentToastfailure()   ///// present a toast if failed to update
            } else {
             this.presentToastsuccess()  ///// present a toast if success 
             this.jobs = res;
         }
          refresh.complete();  
       });        
    });
   }