Skip to content

Commit

Permalink
chore: dispatch event afetr creation
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Jan 10, 2024
1 parent f7e22cd commit ea7cda9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions frontend/src/screens/apps/AppCreated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ export default function AppCreated() {
const [isPopupVisible, setPopupVisible] = useState(false);
const popupRef = useRef<HTMLDivElement>(null);

useEffect(() => {
// dispatch a success event which can be listened to by the opener or by the app that embedded the webview
// this gives those apps the chance to know the user has enabled the connection
const nwcEvent = new CustomEvent("nwc:success", { detail: {} });
window.dispatchEvent(nwcEvent);

// notify the opener of the successful connection
if (window.opener) {
window.opener.postMessage(
{
type: "nwc:success",
payload: { success: true },
},
"*"
);
}
}, []);

useEffect(() => {
const handleClickOutside = (event: MouseEvent) => {
if (
Expand Down

0 comments on commit ea7cda9

Please sign in to comment.