Fix latest empty menu-items not getting active (#194)

This commit is contained in:
Roman Hotsiy 2017-02-02 22:21:47 +02:00
parent 555767feb5
commit 9b6a97fc64
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -52,6 +52,7 @@ export class MenuService {
private _flatItems: MenuItem[];
private _hashSubscription: Subscription;
private _scrollSubscription: Subscription;
private _progressSubscription: Subscription;
private _tagsWithMethods: any;
constructor(
@ -71,6 +72,12 @@ export class MenuService {
this._hashSubscription = this.hash.value.subscribe((hash) => {
this.onHashChange(hash);
});
this._progressSubscription = this.tasks.loadProgress.subscribe(progress => {
if (progress === 100) {
this.makeSureLastItemsEnabled();
}
});
}
get flatItems():MenuItem[] {
@ -88,7 +95,7 @@ export class MenuService {
idx = item.parent.flatIdx;
}
// check if previous items can be enabled
// check if previous items§ can be enabled
let prevItem = this.flatItems[idx -= 1];
while(prevItem && (!prevItem.metadata || !prevItem.items)) {
prevItem.ready = true;
@ -98,6 +105,15 @@ export class MenuService {
this.changed.next();
}
makeSureLastItemsEnabled() {
let lastIdx = this.flatItems.length - 1;
let item = this.flatItems[lastIdx]
while(item && (!item.metadata || !item.items)) {
item.ready = true;
item = this.flatItems[lastIdx -= 1];
}
}
onScroll(isScrolledDown) {
let stable = false;
while(!stable) {