@@ -104,6 +104,7 @@ class StoryStore extends EventEmitter {
104104 }
105105
106106 start ( ) {
107+ if ( typeof window === 'undefined' ) return
107108 if ( SettingsStore . offlineMode ) {
108109 HNServiceRest . storiesRef ( this . type ) . then ( function ( res ) {
109110 return res . json ( )
@@ -125,6 +126,7 @@ class StoryStore extends EventEmitter {
125126 }
126127 firebaseRef = null
127128 }
129+ if ( typeof window === 'undefined' ) return
128130 window . removeEventListener ( 'storage' , this . onStorage )
129131 }
130132}
@@ -142,6 +144,7 @@ extend(StoryStore, {
142144 * Deserialise caches from sessionStorage.
143145 */
144146 loadSession ( ) {
147+ if ( typeof window === 'undefined' ) return
145148 if ( SettingsStore . offlineMode ) {
146149 idCache = parseJSON ( window . localStorage . idCache , { } )
147150 itemCache = parseJSON ( window . localStorage . itemCache , { } )
@@ -156,6 +159,7 @@ extend(StoryStore, {
156159 * Serialise caches to sessionStorage as JSON.
157160 */
158161 saveSession ( ) {
162+ if ( typeof window === 'undefined' ) return
159163 if ( SettingsStore . offlineMode ) {
160164 window . localStorage . setItem ( 'idCache' , JSON . stringify ( idCache ) )
161165 window . localStorage . setItem ( 'itemCache' , JSON . stringify ( itemCache ) )
0 commit comments