Skip to content

Commit

Permalink
Revert "chore: Refactor ConfirmDialog component in theme.script.js"
Browse files Browse the repository at this point in the history
This reverts commit d877e70.
  • Loading branch information
ohitstom committed Jul 8, 2024
1 parent 1ffc8c0 commit d5ddf85
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions Comfy/theme.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,30 +151,27 @@ todo:
const Dialog = Spicetify.React.memo(props => {
const [state, setState] = Spicetify.React.useState(true);
const self = document.querySelector(".ReactModalPortal:last-of-type");
const ConfirmDialog = Spicetify.ReactComponent.ConfirmDialog;
const isForwardRef = typeof ConfirmDialog === "function";
const commonProps = {

Spicetify.React.useEffect(() => {
if (state) {
props.onOpen?.();
}
}, [state]);

return Spicetify.ReactComponent.ConfirmDialog({
...props,
isOpen: state,
onClose: () => {
setState(false);
props.onClose?.();
props.onClose();
self.remove();
},
onConfirm: () => {
setState(false);
props.onConfirm?.();
props.onConfirm();
self.remove();
}
};

Spicetify.React.useEffect(() => {
if (state) {
props.onOpen?.();
}
}, [state]);

return isForwardRef ? ConfirmDialog(commonProps) : Spicetify.React.createElement(ConfirmDialog, commonProps);
});
});

const Section = ({ name, children, condition = true, filter }) => {
Expand Down

0 comments on commit d5ddf85

Please sign in to comment.