Skip to content

Commit

Permalink
Fix: Reset retry count after successful preview (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyjin authored Nov 21, 2017
1 parent eee1525 commit a8f66ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,10 @@ class Preview extends EventEmitter {
// Once the viewer instance has been created, emit it so that clients can attach their events.
// Viewer object will still be sent along the load event also.
this.emit('viewer', this.viewer);

// Reset retry count after successful load so we don't go into the retry short circuit when the same file
// previewed again
this.retryCount = 0;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/lib/__tests__/Preview-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1349,6 +1349,11 @@ describe('lib/Preview', () => {
preview.loadViewer();
expect(stubs.emit).to.be.calledWith('viewer', stubs.viewer);
});

it('should reset retry count', () => {
preview.loadViewer();
expect(preview.retryCount).to.equal(0);
});
});

describe('attachViewerListeners()', () => {
Expand Down

0 comments on commit a8f66ed

Please sign in to comment.