Add disallow on window close in popup mode

This commit is contained in:
artur 2024-02-06 19:03:56 +03:00
parent 14940a4345
commit cc9840760b
3 changed files with 11 additions and 6 deletions

View File

@ -86,8 +86,8 @@ export const ModalConfirmConnect = () => {
}
if (isPopup) {
document.addEventListener('visibilitychange', function() {
if (document.visibilityState == 'hidden') {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
disallow();
}
})

View File

@ -141,7 +141,7 @@ export const ModalConfirmEvent: FC<ModalConfirmEventProps> = ({
if (isPopup) {
document.addEventListener('visibilitychange', () => {
if (document.visibilityState == 'hidden') {
if (document.visibilityState === 'hidden') {
confirmPending(false);
}
})

View File

@ -728,13 +728,18 @@ export class NoauthBackend {
// OAuth flow
const confirmMethod = method === 'connect' ? 'confirm-connect' : 'confirm-event'
const authUrl = `${self.swg.location.origin}/key/${npub}?${confirmMethod}=true&appNpub=${appNpub}&reqId=${id}&popup=true`
backend.rpc.sendResponse(id, remotePubkey, 'auth_url', KIND_RPC, authUrl)
console.log("sending authUrl", authUrl, "for", req)
// NOTE: if you set 'Update on reload' in the Chrome SW console
// then this message will cause a new tab opened by the peer,
// which will cause SW (this code) to reload, to fetch
// the pending requests and to re-send this event,
// looping for 10 seconds (our request age threshold)
backend.rpc.sendResponse(id, remotePubkey, 'auth_url', KIND_RPC, authUrl);
// show notifs
this.notify()
// notify main thread to ask for user concent
// FIXME show a 'confirm' notification?
this.updateUI()
}
})
@ -757,7 +762,7 @@ export class NoauthBackend {
ndk.connect()
const signer = new NDKPrivateKeySigner(sk) // PrivateKeySigner
const backend = new NDKNip46Backend(ndk, sk, () =>
const backend = new NDKNip46Backend(ndk, signer, () =>
Promise.resolve(true),
)
this.keys.push({ npub, backend, signer, ndk, backoff })