mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-04-17 18:46:42 -05:00
Add support for using web service deep links while the web service is open and fix user selection menu for deep links is closed immediately
This commit is contained in:
parent
07a30e89be
commit
41623b1bb3
|
|
@ -58,6 +58,8 @@ export async function askUserForUri(store: Store, uri: string, prompt: string):
|
|||
menu.append(new MenuItem({label: 'Cancel', click: (i, w) => menu.closePopup(w)}));
|
||||
|
||||
const window = new BrowserWindow({show: false});
|
||||
// Add a delay to prevent the menu being closed immediately
|
||||
await new Promise(rs => setTimeout(rs, 100));
|
||||
await new Promise<void>(rs => menu.popup({callback: rs}));
|
||||
window.destroy();
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ export default async function openWebService(
|
|||
|
||||
window.focus();
|
||||
|
||||
const deepLinkingEnabled = webservice.customAttributes.find(a => a.attrKey === 'deepLinkingEnabled');
|
||||
|
||||
if (deepLinkingEnabled?.attrValue === 'true' && qs) {
|
||||
window.webContents.send('nxapi:webserviceapi:deeplink', qs);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -183,14 +189,6 @@ export async function handleOpenWebServiceUri(store: Store, uri: string) {
|
|||
return;
|
||||
}
|
||||
|
||||
const windowid = data.nsoAccount.user.nsaId + ':' + webservice.id;
|
||||
|
||||
if (windows.has(windowid)) {
|
||||
const window = windows.get(windowid)!;
|
||||
window.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
return openWebService(store, selected_user[0], nso, data, webservice, new URL(uri).search.substr(1));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ipcRenderer } from 'electron';
|
||||
import { ipcRenderer, IpcRendererEvent } from 'electron';
|
||||
import { EventEmitter } from 'events';
|
||||
import createDebug from 'debug';
|
||||
import { WebServiceData } from '../main/webservices.js';
|
||||
|
|
@ -25,3 +25,11 @@ debug('Web service', webservice);
|
|||
debug('Web service URL', webserviceurl);
|
||||
|
||||
ipcRenderer.on('nxapi:window:refresh', () => events.emit('window:refresh') || location.reload());
|
||||
|
||||
ipcRenderer.on('nxapi:webserviceapi:deeplink', (event: IpcRendererEvent, qs: string) => {
|
||||
if (events.emit('deeplink', qs)) return;
|
||||
|
||||
const url = new URL(webserviceurl);
|
||||
url.search += (url.search ? '&' : '') + qs;
|
||||
location.href = url.toString();
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user