Add new web service APIs

This commit is contained in:
Samuel Elliott 2023-08-30 20:18:47 +01:00
parent 2680b03c46
commit cb3bdda283
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
4 changed files with 30 additions and 0 deletions

View File

@ -170,6 +170,7 @@ export function setupIpc(appinstance: App, ipcMain: IpcMain) {
ipcMain.handle('nxapi:webserviceapi:copyToClipboard', (e, data: string) => webserviceipc.copyToClipboard(e, data));
ipcMain.handle('nxapi:webserviceapi:downloadImages', (e, data: string) => webserviceipc.downloadImages(e, data));
ipcMain.handle('nxapi:webserviceapi:completeLoading', e => webserviceipc.completeLoading(e));
ipcMain.handle('nxapi:webserviceapi:clearUnreadFlag', e => webserviceipc.clearUnreadFlag(e));
store.on('update-nintendo-accounts', () => sendToAllWindows('nxapi:accounts:shouldrefresh'));
store.on('update-discord-presence-source', () => sendToAllWindows('nxapi:discord:shouldrefresh'));

View File

@ -442,4 +442,10 @@ export class WebServiceIpc {
debug('Web service %s, user %s, called completeLoading', webservice.name, nsoAccount.user.name);
}
async clearUnreadFlag(event: IpcMainInvokeEvent): Promise<void> {
const {nsoAccount, webservice} = this.getWindowData(event.sender);
debug('Web service %s, user %s, called clearUnreadFlag', webservice.name, nsoAccount.user.name);
}
}

View File

@ -20,6 +20,7 @@ const ipc = {
copyToClipboard: (data: string) => ipcRenderer.invoke('nxapi:webserviceapi:copyToClipboard', data) as Promise<void>,
downloadImages: (data: string) => ipcRenderer.invoke('nxapi:webserviceapi:downloadImages', data) as Promise<void>,
completeLoading: () => ipcRenderer.invoke('nxapi:webserviceapi:completeLoading') as Promise<void>,
clearUnreadFlag: () => ipcRenderer.invoke('nxapi:webserviceapi:clearUnreadFlag') as Promise<void>,
};
export default ipc;

View File

@ -142,6 +142,16 @@ interface WebServiceJsApi {
* Used by SplatNet 3.
*/
reloadExtension(): void;
/**
* Clears the unread notifications flag.
*/
clearUnreadFlag(): void;
/**
* Opens a URL in the default browser.
*/
openExternalBrowser(url: string): void;
}
//
@ -339,6 +349,16 @@ function reloadExtension() {
debug('reloadExtension called');
}
function clearUnreadFlag() {
debug('clearUnreadFlag called');
ipc.clearUnreadFlag();
}
function openExternalBrowser(url: string) {
debug('openExternalBrowser called', url);
window.open(url);
}
const api: WebServiceJsApi = {
invokeNativeShare,
invokeNativeShareUrl,
@ -356,6 +376,8 @@ const api: WebServiceJsApi = {
completeLoading,
closeWebView,
reloadExtension,
clearUnreadFlag,
openExternalBrowser,
};
window.jsBridge = api;