Skip to content

Commit

Permalink
issue-store.js: Resolve promise directly at first time
Browse files Browse the repository at this point in the history
This resolves _fetchAllIssues promise directly before polling starts.
The benefit is that users don't need to wait until they see pre-fetched cards.

Closes #173
  • Loading branch information
li-boxuan committed Oct 27, 2018
1 parent 23ff190 commit b81a1b2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/issue-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const issueStore = new class IssueStore extends EventEmitter {
}
}
});
this.isInitialFetch = true;
}
off() { // EventEmitter has `.on` but no matching `.off`
const slice = [].slice;
Expand Down Expand Up @@ -359,10 +360,19 @@ const issueStore = new class IssueStore extends EventEmitter {
_fetchAllIssues(repoInfos, progress, isForced) {
// Start/keep polling
if (!this.polling && isPollingEnabled) {
this.polling = setTimeout(() => {
this.polling = null;
this._fetchAllIssues(repoInfos, progress, true /*isForced*/);
}, getReloadTime());
if (this.isInitialFetch) {
this.isInitialFetch = false;
this.polling = setTimeout(() => {
this.polling = null;
this._fetchAllIssues(repoInfos, progress, true);
});
return Promise.resolve([]);
} else {
this.polling = setTimeout(() => {
this.polling = null;
this._fetchAllIssues(repoInfos, progress, true /*isForced*/);
}, getReloadTime());
}
}
if (!isForced && cacheCards && cacheCardsRepoInfos === JSON.stringify(repoInfos)) {
return Promise.resolve(cacheCards);
Expand Down

0 comments on commit b81a1b2

Please sign in to comment.