no early return between hooks (#16142)

This commit is contained in:
Kashargul
2024-07-31 12:16:05 +02:00
committed by GitHub
parent 05940866d5
commit 501850fa16
3 changed files with 26 additions and 27 deletions
+24 -25
View File
@@ -50,36 +50,35 @@ export const Window = (props: Props) => {
} = props;
const { config, suspended } = useBackend();
if (suspended) {
return;
}
const { debugLayout = false } = useDebug();
useEffect(() => {
const updateGeometry = () => {
const options = {
...config.window,
size: DEFAULT_SIZE,
if (!suspended) {
const updateGeometry = () => {
const options = {
...config.window,
size: DEFAULT_SIZE,
};
if (width && height) {
options.size = [width, height];
}
if (config.window?.key) {
setWindowKey(config.window.key);
}
recallWindowGeometry(options);
};
if (width && height) {
options.size = [width, height];
}
if (config.window?.key) {
setWindowKey(config.window.key);
}
recallWindowGeometry(options);
};
Byond.winset(Byond.windowId, {
'can-close': Boolean(canClose),
});
logger.log('mounting');
updateGeometry();
Byond.winset(Byond.windowId, {
'can-close': Boolean(canClose),
});
logger.log('mounting');
updateGeometry();
return () => {
logger.log('unmounting');
};
return () => {
logger.log('unmounting');
};
}
}, [width, height]);
const dispatch = globalStore.dispatch;
@@ -92,7 +91,7 @@ export const Window = (props: Props) => {
? config.status < UI_DISABLED
: config.status < UI_INTERACTIVE);
return (
return suspended ? null : (
<Layout className="Window" theme={theme}>
<TitleBar
className="Window__titleBar"
+1 -1
View File
@@ -480,7 +480,7 @@
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/function F(){return F=Object.assign||function(Z){for(var U=1;U<arguments.length;U++){var $=arguments[U];for(var X in $)Object.prototype.hasOwnProperty.call($,X)&&(Z[X]=$[X])}return Z},F.apply(this,arguments)}function D(Z,U){if(Z==null)return{};var $={},X=Object.keys(Z),H,Y;for(Y=0;Y<X.length;Y++)H=X[Y],!(U.indexOf(H)>=0)&&($[H]=Z[H]);return $}var w=(0,M.h)("Window"),N=[400,600],B=function(Z){var U,$=Z.canClose,X=$===void 0?!0:$,H=Z.theme,Y=Z.title,lt=Z.children,nt=Z.buttons,dt=Z.width,ct=Z.height,jt=(0,S.Oc)(),vt=jt.config,pt=jt.suspended;if(!pt){var Dt=(0,A.Lo)(),ce=Dt.debugLayout,fe=ce===void 0?!1:ce;(0,i.useEffect)(function(){var Ft=function(){var Bt,oe=F({},vt.window,{size:N});dt&&ct&&(oe.size=[dt,ct]),(Bt=vt.window)!=null&&Bt.key&&(0,b.y9)(vt.window.key),(0,b.C8)(oe)};return Byond.winset(Byond.windowId,{"can-close":!!X}),w.log("mounting"),Ft(),function(){w.log("unmounting")}},[dt,ct]);var Xt=S.J3.dispatch,It=(U=vt.window)==null?void 0:U.fancy,Mt=vt.user&&(vt.user.observer?vt.status<O.KS:vt.status<O.KA);return(0,n.jsxs)(g,{className:"Window",theme:H,children:[(0,n.jsx)(K,{className:"Window__titleBar",title:Y||(0,I.jT)(vt.title),status:vt.status,fancy:It,onDragStart:b.BF,onClose:function(){w.log("pressed close"),Xt((0,S.JV)())},canClose:X,children:nt}),(0,n.jsxs)("div",{className:(0,o.Ly)(["Window__rest",fe&&"debug-layout"]),children:[!pt&&lt,Mt&&(0,n.jsx)("div",{className:"Window__dimmer"})]}),It&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"Window__resizeHandle__e",onMouseDown:(0,b.nZ)(1,0)}),(0,n.jsx)("div",{className:"Window__resizeHandle__s",onMouseDown:(0,b.nZ)(0,1)}),(0,n.jsx)("div",{className:"Window__resizeHandle__se",onMouseDown:(0,b.nZ)(1,1)})]})]})}},L=function(Z){var U=Z.className,$=Z.fitted,X=Z.children,H=D(Z,["className","fitted","children"]);return(0,n.jsx)(g.Content,F({className:(0,o.Ly)(["Window__content",U])},H,{children:$&&X||(0,n.jsx)("div",{className:"Window__contentPadding",children:X})}))};B.Content=L;var W=function(Z){switch(Z){case O.KA:return"good";case O.bz:return"average";case O.KS:default:return"bad"}},K=function(Z){var U=Z.className,$=Z.title,X=Z.status,H=Z.canClose,Y=Z.fancy,lt=Z.onDragStart,nt=Z.onClose,dt=Z.children,ct=S.J3.dispatch,jt=typeof $=="string"&&$===$.toLowerCase()&&(0,I.Sn)($)||$;return(0,n.jsxs)("div",{className:(0,o.Ly)(["TitleBar",U]),children:[X===void 0&&(0,n.jsx)(E.In,{className:"TitleBar__statusIcon",name:"tools",opacity:.5})||(0,n.jsx)(E.In,{className:"TitleBar__statusIcon",color:W(X),name:"eye"}),(0,n.jsx)("div",{className:"TitleBar__dragZone",onMouseDown:function(vt){return Y&&lt&&lt(vt)}}),(0,n.jsxs)("div",{className:"TitleBar__title",children:[jt,!!dt&&(0,n.jsx)("div",{className:"TitleBar__buttons",children:dt})]}),!1,!!(Y&&H)&&(0,n.jsx)("div",{className:"TitleBar__close TitleBar__clickable",onClick:nt,children:"\xD7"})]})};/**
*/function F(){return F=Object.assign||function(Z){for(var U=1;U<arguments.length;U++){var $=arguments[U];for(var X in $)Object.prototype.hasOwnProperty.call($,X)&&(Z[X]=$[X])}return Z},F.apply(this,arguments)}function D(Z,U){if(Z==null)return{};var $={},X=Object.keys(Z),H,Y;for(Y=0;Y<X.length;Y++)H=X[Y],!(U.indexOf(H)>=0)&&($[H]=Z[H]);return $}var w=(0,M.h)("Window"),N=[400,600],B=function(Z){var U,$=Z.canClose,X=$===void 0?!0:$,H=Z.theme,Y=Z.title,lt=Z.children,nt=Z.buttons,dt=Z.width,ct=Z.height,jt=(0,S.Oc)(),vt=jt.config,pt=jt.suspended,Dt=(0,A.Lo)(),ce=Dt.debugLayout,fe=ce===void 0?!1:ce;(0,i.useEffect)(function(){if(!pt){var Ft=function(){var Bt,oe=F({},vt.window,{size:N});dt&&ct&&(oe.size=[dt,ct]),(Bt=vt.window)!=null&&Bt.key&&(0,b.y9)(vt.window.key),(0,b.C8)(oe)};return Byond.winset(Byond.windowId,{"can-close":!!X}),w.log("mounting"),Ft(),function(){w.log("unmounting")}}},[dt,ct]);var Xt=S.J3.dispatch,It=(U=vt.window)==null?void 0:U.fancy,Mt=vt.user&&(vt.user.observer?vt.status<O.KS:vt.status<O.KA);return pt?null:(0,n.jsxs)(g,{className:"Window",theme:H,children:[(0,n.jsx)(K,{className:"Window__titleBar",title:Y||(0,I.jT)(vt.title),status:vt.status,fancy:It,onDragStart:b.BF,onClose:function(){w.log("pressed close"),Xt((0,S.JV)())},canClose:X,children:nt}),(0,n.jsxs)("div",{className:(0,o.Ly)(["Window__rest",fe&&"debug-layout"]),children:[!pt&&lt,Mt&&(0,n.jsx)("div",{className:"Window__dimmer"})]}),It&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"Window__resizeHandle__e",onMouseDown:(0,b.nZ)(1,0)}),(0,n.jsx)("div",{className:"Window__resizeHandle__s",onMouseDown:(0,b.nZ)(0,1)}),(0,n.jsx)("div",{className:"Window__resizeHandle__se",onMouseDown:(0,b.nZ)(1,1)})]})]})},L=function(Z){var U=Z.className,$=Z.fitted,X=Z.children,H=D(Z,["className","fitted","children"]);return(0,n.jsx)(g.Content,F({className:(0,o.Ly)(["Window__content",U])},H,{children:$&&X||(0,n.jsx)("div",{className:"Window__contentPadding",children:X})}))};B.Content=L;var W=function(Z){switch(Z){case O.KA:return"good";case O.bz:return"average";case O.KS:default:return"bad"}},K=function(Z){var U=Z.className,$=Z.title,X=Z.status,H=Z.canClose,Y=Z.fancy,lt=Z.onDragStart,nt=Z.onClose,dt=Z.children,ct=S.J3.dispatch,jt=typeof $=="string"&&$===$.toLowerCase()&&(0,I.Sn)($)||$;return(0,n.jsxs)("div",{className:(0,o.Ly)(["TitleBar",U]),children:[X===void 0&&(0,n.jsx)(E.In,{className:"TitleBar__statusIcon",name:"tools",opacity:.5})||(0,n.jsx)(E.In,{className:"TitleBar__statusIcon",color:W(X),name:"eye"}),(0,n.jsx)("div",{className:"TitleBar__dragZone",onMouseDown:function(vt){return Y&&lt&&lt(vt)}}),(0,n.jsxs)("div",{className:"TitleBar__title",children:[jt,!!dt&&(0,n.jsx)("div",{className:"TitleBar__buttons",children:dt})]}),!1,!!(Y&&H)&&(0,n.jsx)("div",{className:"TitleBar__close TitleBar__clickable",onClick:nt,children:"\xD7"})]})};/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
+1 -1
View File
@@ -300,7 +300,7 @@
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/function M(){return M=Object.assign||function(q){for(var Z=1;Z<arguments.length;Z++){var X=arguments[Z];for(var H in X)Object.prototype.hasOwnProperty.call(X,H)&&(q[H]=X[H])}return q},M.apply(this,arguments)}function P(q,Z){if(q==null)return{};var X={},H=Object.keys(q),V,J;for(J=0;J<H.length;J++)V=H[J],!(Z.indexOf(V)>=0)&&(X[V]=q[V]);return X}var D=(0,O.h)("Window"),S=[400,600],B=function(q){var Z,X=q.canClose,H=X===void 0?!0:X,V=q.theme,J=q.title,ce=q.children,le=q.buttons,fe=q.width,he=q.height,_e=(0,a.Oc)(),xe=_e.config,je=_e.suspended;if(!je){var Re=(0,v.Lo)(),qe=Re.debugLayout,Fe=qe===void 0?!1:qe;(0,t.useEffect)(function(){var mn=function(){var cn,En=M({},xe.window,{size:S});fe&&he&&(En.size=[fe,he]),(cn=xe.window)!=null&&cn.key&&(0,E.y9)(xe.window.key),(0,E.C8)(En)};return Byond.winset(Byond.windowId,{"can-close":!!H}),D.log("mounting"),mn(),function(){D.log("unmounting")}},[fe,he]);var Pe=a.J3.dispatch,He=(Z=xe.window)==null?void 0:Z.fancy,gn=xe.user&&(xe.user.observer?xe.status<m.KS:xe.status<m.KA);return(0,e.jsxs)(u,{className:"Window",theme:V,children:[(0,e.jsx)(W,{className:"Window__titleBar",title:J||(0,f.jT)(xe.title),status:xe.status,fancy:He,onDragStart:E.BF,onClose:function(){D.log("pressed close"),Pe((0,a.JV)())},canClose:H,children:le}),(0,e.jsxs)("div",{className:(0,i.Ly)(["Window__rest",Fe&&"debug-layout"]),children:[!je&&ce,gn&&(0,e.jsx)("div",{className:"Window__dimmer"})]}),He&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"Window__resizeHandle__e",onMouseDown:(0,E.nZ)(1,0)}),(0,e.jsx)("div",{className:"Window__resizeHandle__s",onMouseDown:(0,E.nZ)(0,1)}),(0,e.jsx)("div",{className:"Window__resizeHandle__se",onMouseDown:(0,E.nZ)(1,1)})]})]})}},T=function(q){var Z=q.className,X=q.fitted,H=q.children,V=P(q,["className","fitted","children"]);return(0,e.jsx)(u.Content,M({className:(0,i.Ly)(["Window__content",Z])},V,{children:X&&H||(0,e.jsx)("div",{className:"Window__contentPadding",children:H})}))};B.Content=T;var U=function(q){switch(q){case m.KA:return"good";case m.bz:return"average";case m.KS:default:return"bad"}},W=function(q){var Z=q.className,X=q.title,H=q.status,V=q.canClose,J=q.fancy,ce=q.onDragStart,le=q.onClose,fe=q.children,he=a.J3.dispatch,_e=typeof X=="string"&&X===X.toLowerCase()&&(0,f.Sn)(X)||X;return(0,e.jsxs)("div",{className:(0,i.Ly)(["TitleBar",Z]),children:[H===void 0&&(0,e.jsx)(l.In,{className:"TitleBar__statusIcon",name:"tools",opacity:.5})||(0,e.jsx)(l.In,{className:"TitleBar__statusIcon",color:U(H),name:"eye"}),(0,e.jsx)("div",{className:"TitleBar__dragZone",onMouseDown:function(xe){return J&&ce&&ce(xe)}}),(0,e.jsxs)("div",{className:"TitleBar__title",children:[_e,!!fe&&(0,e.jsx)("div",{className:"TitleBar__buttons",children:fe})]}),!1,!!(J&&V)&&(0,e.jsx)("div",{className:"TitleBar__close TitleBar__clickable",onClick:le,children:"\xD7"})]})};/**
*/function M(){return M=Object.assign||function(q){for(var Z=1;Z<arguments.length;Z++){var X=arguments[Z];for(var H in X)Object.prototype.hasOwnProperty.call(X,H)&&(q[H]=X[H])}return q},M.apply(this,arguments)}function P(q,Z){if(q==null)return{};var X={},H=Object.keys(q),V,J;for(J=0;J<H.length;J++)V=H[J],!(Z.indexOf(V)>=0)&&(X[V]=q[V]);return X}var D=(0,O.h)("Window"),S=[400,600],B=function(q){var Z,X=q.canClose,H=X===void 0?!0:X,V=q.theme,J=q.title,ce=q.children,le=q.buttons,fe=q.width,he=q.height,_e=(0,a.Oc)(),xe=_e.config,je=_e.suspended,Re=(0,v.Lo)(),qe=Re.debugLayout,Fe=qe===void 0?!1:qe;(0,t.useEffect)(function(){if(!je){var mn=function(){var cn,En=M({},xe.window,{size:S});fe&&he&&(En.size=[fe,he]),(cn=xe.window)!=null&&cn.key&&(0,E.y9)(xe.window.key),(0,E.C8)(En)};return Byond.winset(Byond.windowId,{"can-close":!!H}),D.log("mounting"),mn(),function(){D.log("unmounting")}}},[fe,he]);var Pe=a.J3.dispatch,He=(Z=xe.window)==null?void 0:Z.fancy,gn=xe.user&&(xe.user.observer?xe.status<m.KS:xe.status<m.KA);return je?null:(0,e.jsxs)(u,{className:"Window",theme:V,children:[(0,e.jsx)(W,{className:"Window__titleBar",title:J||(0,f.jT)(xe.title),status:xe.status,fancy:He,onDragStart:E.BF,onClose:function(){D.log("pressed close"),Pe((0,a.JV)())},canClose:H,children:le}),(0,e.jsxs)("div",{className:(0,i.Ly)(["Window__rest",Fe&&"debug-layout"]),children:[!je&&ce,gn&&(0,e.jsx)("div",{className:"Window__dimmer"})]}),He&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{className:"Window__resizeHandle__e",onMouseDown:(0,E.nZ)(1,0)}),(0,e.jsx)("div",{className:"Window__resizeHandle__s",onMouseDown:(0,E.nZ)(0,1)}),(0,e.jsx)("div",{className:"Window__resizeHandle__se",onMouseDown:(0,E.nZ)(1,1)})]})]})},T=function(q){var Z=q.className,X=q.fitted,H=q.children,V=P(q,["className","fitted","children"]);return(0,e.jsx)(u.Content,M({className:(0,i.Ly)(["Window__content",Z])},V,{children:X&&H||(0,e.jsx)("div",{className:"Window__contentPadding",children:H})}))};B.Content=T;var U=function(q){switch(q){case m.KA:return"good";case m.bz:return"average";case m.KS:default:return"bad"}},W=function(q){var Z=q.className,X=q.title,H=q.status,V=q.canClose,J=q.fancy,ce=q.onDragStart,le=q.onClose,fe=q.children,he=a.J3.dispatch,_e=typeof X=="string"&&X===X.toLowerCase()&&(0,f.Sn)(X)||X;return(0,e.jsxs)("div",{className:(0,i.Ly)(["TitleBar",Z]),children:[H===void 0&&(0,e.jsx)(l.In,{className:"TitleBar__statusIcon",name:"tools",opacity:.5})||(0,e.jsx)(l.In,{className:"TitleBar__statusIcon",color:U(H),name:"eye"}),(0,e.jsx)("div",{className:"TitleBar__dragZone",onMouseDown:function(xe){return J&&ce&&ce(xe)}}),(0,e.jsxs)("div",{className:"TitleBar__title",children:[_e,!!fe&&(0,e.jsx)("div",{className:"TitleBar__buttons",children:fe})]}),!1,!!(J&&V)&&(0,e.jsx)("div",{className:"TitleBar__close TitleBar__clickable",onClick:le,children:"\xD7"})]})};/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT