Skip to content

Commit

Permalink
Update SessionManager.ts
Browse files Browse the repository at this point in the history
Stop crashing if someone wanted to import the library in an SSR enabled app. keratin#30
  • Loading branch information
InstanceOfMichael authored Sep 21, 2019
1 parent 4227a1b commit cf71ee5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/SessionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ export default class SessionManager {
// immediately hook into visibility changes. strange things can happen to timeouts while a device
// is asleep, so we want to reset them.
constructor() {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
this.scheduleRefresh();
};
});
if (typeof document !== 'undefined') {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
this.scheduleRefresh();
};
});
}
}

setStore(store: SessionStore): void {
Expand Down

0 comments on commit cf71ee5

Please sign in to comment.