feat: SDA-1973 (Expose notifications APIs for mana) (#998)

* SDA-1973 - Expose notifications APIs for mana

* SDA-1973 - Calculate offset for all corners
This commit is contained in:
Kiran Niranjan 2020-05-19 11:36:51 +05:30 committed by GitHub
parent 401120dbea
commit 5983b090e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -78,24 +78,30 @@ export default class NotificationHandler {
}
const display = this.externalDisplay || electron.screen.getPrimaryDisplay();
this.settings.corner.x = display.workArea.x - (isMac || isLinux ? 20 : 10);
this.settings.corner.y = display.workArea.y + (isMac || isLinux ? 20 : 10);
this.settings.corner.x = display.workArea.x;
this.settings.corner.y = display.workArea.y;
// update corner x/y based on corner of screen where notification should appear
const workAreaWidth = display.workAreaSize.width;
const workAreaHeight = display.workAreaSize.height;
const offSet = (isMac || isLinux ? 20 : 10);
switch (this.settings.startCorner) {
case 'upper-right':
this.settings.corner.x += workAreaWidth;
this.settings.corner.x += workAreaWidth - offSet;
this.settings.corner.y += offSet;
break;
case 'lower-right':
this.settings.corner.x += workAreaWidth;
this.settings.corner.y += workAreaHeight;
this.settings.corner.x += workAreaWidth - offSet;
this.settings.corner.y += workAreaHeight - offSet;
break;
case 'lower-left':
this.settings.corner.y += workAreaHeight;
this.settings.corner.x += offSet;
this.settings.corner.y += workAreaHeight - offSet;
break;
case 'upper-left':
this.settings.corner.x += offSet;
this.settings.corner.y += offSet;
break;
default:
// no change needed
break;

View File

@ -1,4 +1,4 @@
import { contextBridge, ipcRenderer, webFrame } from 'electron';
import { contextBridge, ipcRenderer, remote, webFrame } from 'electron';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { apiCmds, apiName } from '../common/api-interface';
@ -22,6 +22,7 @@ const minMemoryFetchInterval = 4 * 60 * 60 * 1000;
const maxMemoryFetchInterval = 12 * 60 * 60 * 1000;
const snackBar = new SnackBar();
const banner = new MessageBanner();
const notification = remote.require('../renderer/notification').notification;
/**
* creates API exposed from electron.
@ -81,6 +82,8 @@ if (ssfWindow.ssf) {
registerRestartFloater: ssfWindow.ssf.registerRestartFloater,
setCloudConfig: ssfWindow.ssf.setCloudConfig,
checkMediaPermission: ssfWindow.ssf.checkMediaPermission,
showNotification: notification.showNotification,
closeNotification: notification.hideNotification,
});
}