+
\ No newline at end of file
diff --git a/src/components/infinite-loading/infinite-loading.ts b/src/components/infinite-loading/infinite-loading.ts
index 101e303d4..977eba6b7 100644
--- a/src/components/infinite-loading/infinite-loading.ts
+++ b/src/components/infinite-loading/infinite-loading.ts
@@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-import { Component, Input, Output, EventEmitter, OnChanges, SimpleChange, Optional } from '@angular/core';
+import { Component, Input, Output, EventEmitter, OnChanges, SimpleChange, Optional, ViewChild, ElementRef } from '@angular/core';
import { InfiniteScroll, Content } from 'ionic-angular';
+import { CoreDomUtilsProvider } from '@providers/utils/dom';
/**
* Component to show a infinite loading trigger and spinner while more data is being loaded.
@@ -31,11 +32,16 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
@Input() position = 'bottom';
@Output() action: EventEmitter<() => void>; // Will emit an event when triggered.
+ @ViewChild('topbutton') topButton: ElementRef;
+ @ViewChild('infinitescroll') infiniteEl: ElementRef;
+ @ViewChild('bottombutton') bottomButton: ElementRef;
+ @ViewChild('spinnercontainer') spinnerContainer: ElementRef;
+
loadingMore = false; // Hide button and avoid loading more.
protected infiniteScroll: InfiniteScroll;
- constructor(@Optional() private content: Content) {
+ constructor(@Optional() private content: Content, private domUtils: CoreDomUtilsProvider) {
this.action = new EventEmitter();
}
@@ -77,6 +83,18 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
* Complete loading.
*/
complete(): void {
+ if (this.position == 'top') {
+ // Wait a bit before allowing loading more, otherwise it could be re-triggered automatically when it shouldn't.
+ setTimeout(this.completeLoadMore.bind(this), 400);
+ } else {
+ this.completeLoadMore();
+ }
+ }
+
+ /**
+ * Complete loading.
+ */
+ protected completeLoadMore(): void {
this.loadingMore = false;
this.infiniteScroll && this.infiniteScroll.complete();
this.infiniteScroll = undefined;
@@ -89,4 +107,28 @@ export class CoreInfiniteLoadingComponent implements OnChanges {
});
}
+ /**
+ * Get the height of the element.
+ *
+ * @return {number} Height.
+ */
+ getHeight(): number {
+ return this.getElementHeight(this.topButton) + this.getElementHeight(this.infiniteEl) +
+ this.getElementHeight(this.bottomButton) + this.getElementHeight(this.spinnerContainer);
+ }
+
+ /**
+ * Get the height of an element.
+ *
+ * @param {ElementRef} element Element ref.
+ * @return {number} Height.
+ */
+ protected getElementHeight(element: ElementRef): number {
+ if (element && element.nativeElement) {
+ return this.domUtils.getElementHeight(element.nativeElement, true, true, true);
+ }
+
+ return 0;
+ }
+
}
diff --git a/src/components/user-avatar/user-avatar.ts b/src/components/user-avatar/user-avatar.ts
index cb1243e1d..a8e9d6bc7 100644
--- a/src/components/user-avatar/user-avatar.ts
+++ b/src/components/user-avatar/user-avatar.ts
@@ -44,7 +44,6 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
// Variable to check if we consider this user online or not.
// @TODO: Use setting when available (see MDL-63972) so we can use site setting.
protected timetoshowusers = 300000; // Miliseconds default.
- protected myUser = false;
protected currentUserId: number;
protected pictureObs;
@@ -91,9 +90,6 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
this.userId = this.userId || (this.user && (this.user.userid || this.user.id));
this.courseId = this.courseId || (this.user && this.user.courseid);
-
- // If not available we cannot ensure the avatar is from the current user.
- this.myUser = this.userId && this.userId == this.currentUserId;
}
/**
@@ -102,7 +98,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
* @return boolean
*/
isOnline(): boolean {
- if (this.myUser || this.utils.isFalseOrZero(this.user.isonline)) {
+ if (this.utils.isFalseOrZero(this.user.isonline)) {
return false;
}