(self.webpackChunkmattermost_webapp=self.webpackChunkmattermost_webapp||[]).push([[865],{48865:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>I}),n(4723);var o=n(37703),i=n(14890),s=n(65710),r=n(18432),a=n(78781),c=n(92701),d=n(89262),u=n(59930),l=n(74935),p=n(45697),m=n.n(p),h=n(67294),w=n(5977),f=n(94895),v=n(81249),g=n.n(v),b=n(34288),L=n(45672),U=n(47470),k=n(19476),C=n(58367),T=n(26739),_=n(58194),E=n(91384);function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const R=T.Z.dispatch,S=T.Z.getState;class y extends h.PureComponent{constructor(e){super(e),z(this,"onDesktopMessageListener",(({origin:e,data:{type:t,message:n={}}={}}={})=>{if(this.props.currentUser&&e===window.location.origin)switch(t){case"register-desktop":{const{version:e}=n;window.desktop||(window.desktop={}),window.desktop.version=g().valid(g().coerce(e));break}case"user-activity-update":{const{userIsActive:e,manual:t}=n;!0!==e&&!1!==e||_.Z.userUpdateActiveStatus(e,t);break}case"notification-clicked":{const{channel:e,teamId:t}=n;window.focus(),this.props.actions.getChannelURLAction(e,t);break}}})),z(this,"handleBackSpace",(e=>{8!==e.which||["input","textarea"].includes(e.target.tagName.toLowerCase())||e.preventDefault()})),z(this,"handleBeforeUnload",(()=>{window.removeEventListener("beforeunload",this.handleBeforeUnload),document.cookie.indexOf("MMUSERID=")>-1&&(0,f.viewChannel)("",this.props.currentChannelId||"")(R,S),L.xv()}));const t=document.getElementById("root");t&&(t.className+=" channel-view")}isValidState(){return null!=this.props.currentUser}componentDidMount(){if(L.j2(),this.props.enableTimezone&&this.props.actions.autoUpdateTimezone((0,C.x_)()),window.addEventListener("beforeunload",this.handleBeforeUnload),window.addEventListener("focus",this.onFocusListener),window.addEventListener("blur",this.onBlurListener),document.hasFocus()||b.UF(!1),window.addEventListener("message",this.onDesktopMessageListener),window.postMessage({type:"webapp-ready"},window.location.origin),U.s()?document.body.classList.add("ios"):U.Dt()&&document.body.classList.add("android"),!this.props.currentUser){const e=document.getElementById("root");e&&e.setAttribute("class",""),b.gc("/login?redirect_to="+encodeURIComponent(this.props.location.pathname),!0,!1)}window.addEventListener("keydown",this.handleBackSpace),this.isValidState()&&E.Z.signalLogin()}componentWillUnmount(){L.xv(),window.removeEventListener("keydown",this.handleBackSpace),window.removeEventListener("focus",this.onFocusListener),window.removeEventListener("blur",this.onBlurListener),window.removeEventListener("message",this.onDesktopMessageListener)}render(){if(!this.isValidState())return h.createElement(k.Z,null);if(this.props.mfaRequired){if("/mfa/setup"!==this.props.location.pathname)return h.createElement(w.l_,{to:"/mfa/setup"})}else if("/mfa/confirm"===this.props.location.pathname);else if(this.props.showTermsOfService&&"/terms_of_service"!==this.props.location.pathname)return h.createElement(w.l_,{to:"/terms_of_service?redirect_to="+encodeURIComponent(this.props.location.pathname)});return this.props.children}onFocusListener(){b.UF(!0)}onBlurListener(){b.UF(!1)}}z(y,"propTypes",{currentUser:m().object,currentChannelId:m().string,children:m().object,mfaRequired:m().bool.isRequired,enableTimezone:m().bool.isRequired,actions:m().shape({autoUpdateTimezone:m().func.isRequired,getChannelURLAction:m().func.isRequired}).isRequired,showTermsOfService:m().bool.isRequired});const B=(e,t)=>(n,o)=>d.m.push((0,l.qr)(o(),e,t)),I=(0,o.connect)((function(e,t){const n=(0,a.getLicense)(e),o=(0,a.getConfig)(e),i=(0,c.shouldShowTermsOfService)(e);return{currentUser:(0,c.getCurrentUser)(e),currentChannelId:(0,r.getCurrentChannelId)(e),mfaRequired:(0,u.b2)((0,c.getCurrentUser)(e),n,o,t.match.url),enableTimezone:"true"===o.ExperimentalTimezone,showTermsOfService:i}}),(function(e){return{actions:(0,i.bindActionCreators)({autoUpdateTimezone:s.g,getChannelURLAction:B},e)}}))(y)},65710:(e,t,n)=>{"use strict";t.g=void 0;var o=n(98477),i=n(92701),s=n(96226),r=n(12543);t.g=function(e){var t=this;return function(n,a){return o.__awaiter(t,void 0,void 0,(function(){var t,c,d,u,l;return o.__generator(this,(function(p){return t=i.getCurrentUser(a()),c=s.getUserTimezone(a(),t.id),d=c.automaticTimezone!==e,c.useAutomaticTimezone&&d&&(u={useAutomaticTimezone:"true",automaticTimezone:e,manualTimezone:c.manualTimezone},l=o.__assign(o.__assign({},t),{timezone:u}),r.updateMe(l)(n,a)),[2]}))}))}}}}]);
//# sourceMappingURL=865.8658c376d96b50ee5b20.js.map