Skip to content

Commit

Permalink
fix: do not hang when swagger doesn't contain any paths
Browse files Browse the repository at this point in the history
closes #216
  • Loading branch information
RomanHotsiy committed Mar 9, 2017
1 parent 3e09b05 commit e4f5388
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/services/menu.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class MenuService {
onHashChange(hash?: string) {
if (hash == undefined) return;
let activated = this.activateByHash(hash);
if (!this.tasks.empty) {
if (!this.tasks.processed) {
this.tasks.start(this.activeIdx, this);
this.scrollService.setStickElement(this.getCurrentEl());
if (activated) this.scrollToActive();
Expand Down
14 changes: 12 additions & 2 deletions lib/shared/components/LazyFor/lazy-for.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ export class LazyTasksService {
private _tasks = [];
private _current: number = 0;
private _syncCount: number = 0;
private _emptyProcessed = false;
private menuService;

public loadProgress = new BehaviorSubject<number>(0);
public allSync = false;
constructor(public optionsService: OptionsService) {
}

get empty() {
return this._current === this._tasks.length;
get processed() {
let res = this._tasks.length && (this._current >= this._tasks.length) || this._emptyProcessed;
if (!this._tasks.length) this._emptyProcessed = true;
return res;
}

set syncCount(n: number) {
Expand Down Expand Up @@ -97,10 +100,17 @@ export class LazyTasksService {
} else {
this.sortTasks(idx);
}
syncCount = Math.min(syncCount, this._tasks.length);
if (this.allSync) syncCount = this._tasks.length;
for (var i = this._current; i < syncCount; i++) {
this.nextTaskSync();
}

if (!this._tasks.length) {
this.loadProgress.next(100);
return;
}

this.nextTask();
}
}
Expand Down

0 comments on commit e4f5388

Please sign in to comment.