Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Ionic 5, ion refresher error on android

$
0
0

I have a problem on an app in ionic 5,
in paigna I have an ion-refresher and an ion-virtual-scroll at the first access to the page the virtual scrol works correctly.
When I reload the page the method declared in the ion-refresher is called every time I try to scroll the page.

    <ion-refresher slot="fixed" (ionRefresh)="doRefresh($event)">
        <ion-refresher-content></ion-refresher-content>
    </ion-refresher>
      <ion-virtual-scroll [items]="address" approxItemHeight="61px">
            <div *virtualItem="let a;let itemBounds = bounds;">
                <div class="divider"
                     *ngIf="a.key">
                    <h4>{{a.key}}</h4>
                </div>
                <ion-item class="ion-activatable ripple-parent"
                          *ngIf="a.username"
                          (click)="forward(a)">
                    <div class="image-container">
                        <div *ngIf="!a.profileImage"
                             [style.background-image]="getSafeStyle('assets/default-user.jpg')"></div>
                        <div *ngIf="a.profileImage"
                             [style.background-image]="getSafeStyle(a.profileImage)"></div>
                    </div>
                    <ion-label>{{a.lastName}} {{a.firstName}}</ion-label>
                    <ion-ripple-effect></ion-ripple-effect>
                </ion-item>
            </div>
        </ion-virtual-scroll>

in te componente

    doRefresh(event) {
        event.target.complete();
        this.isLoading = true;
        this.getContacts();
    }
    getContacts() {
        this.allAddress = [];
        this.address = [];
        console.log('Address book search', this.filtersForm.value.searchValue);
        this.addressBookService.getContacts(
            this.filtersForm.value.searchValue,
            this.departments,
            this.online
        ).pipe(
            map(a => {
                if (a === -1) {
                    throw a;
                } else {
                    return a;
                }
            }),
            retryWhen(errors => errors.pipe(delay(1000), take(10)))
        ).subscribe(address => {
            let tmp = {}
            tmp = address.reduce((acc, obj) => {
                let key = '#';
                if (obj.lastName) {
                    key = obj.lastName.charAt(0);
                }
                if (!acc[key]) {
                    acc[key] = [];
                }
                acc[key].push(obj);
                return acc;
            }, {}) as { [key: string]: AddressProfile[] };
            for (let k in tmp) {
                this.address.push({key: k})
                this.address = this.address.concat(tmp[k])
            }
            this.isLoading = false;
            this.cd.detectChanges();
        });
    }

It seems to me that it never completes the event or that it is continuously unleashed

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>