@@ -31,6 +31,7 @@ import { USERS_EDIT, VIEW_CONTEXT_HOME } from 'amo/constants';
3131import { withFixedErrorHandler } from 'amo/errorHandler' ;
3232import log from 'amo/logger' ;
3333import translate from 'amo/i18n/translate' ;
34+ import universalWindow from 'amo/window' ;
3435import { sanitizeHTML } from 'amo/utils' ;
3536import Button from 'amo/components/Button' ;
3637import Card from 'amo/components/Card' ;
@@ -70,7 +71,7 @@ type PropsFromState = {|
7071| } ;
7172
7273type DefaultProps = { |
73- _window : typeof window | Object ,
74+ _window : typeof window ,
7475| } ;
7576
7677type InternalProps = { |
@@ -108,7 +109,7 @@ type State = {|
108109
109110export class UserProfileEditBase extends React . Component < InternalProps , State > {
110111 static defaultProps : DefaultProps = {
111- _window : typeof window !== 'undefined' ? window : { } ,
112+ _window : universalWindow ,
112113 } ;
113114
114115 constructor ( props : InternalProps ) {
@@ -157,6 +158,7 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
157158 } = prevProps ;
158159
159160 const {
161+ _window,
160162 clientApp,
161163 currentUser,
162164 dispatch,
@@ -218,24 +220,22 @@ export class UserProfileEditBase extends React.Component<InternalProps, State> {
218220 toPath = url . parse ( toPath ) . pathname ;
219221 if ( toPath && ! toPath . startsWith ( '//' ) ) {
220222 try {
221- this . props . _window . location . assign ( toPath ) ;
223+ _window . location . assign ( toPath ) ;
222224 return ;
223225 } catch ( error ) {
224226 log . warn ( `Error redirecting to location: ${ toPath } : ${ error } ` ) ;
225227 }
226228 }
227229 }
228- this . props . _window . location . assign (
229- `/${ lang } /${ clientApp } /user/${ newUserId } /` ,
230- ) ;
230+ _window . location . assign ( `/${ lang } /${ clientApp } /user/${ newUserId } /` ) ;
231231 }
232232
233233 if (
234234 ( ! prevProps . errorHandler . hasError ( ) &&
235235 this . props . errorHandler . hasError ( ) ) ||
236236 ( ! prevState . successMessage && this . state . successMessage )
237237 ) {
238- this . props . _window . scroll ( 0 , 0 ) ;
238+ _window . scroll ( 0 , 0 ) ;
239239 }
240240 }
241241
0 commit comments