Skip to content

Commit

Permalink
fix: #240 Merge branch 'micw-feature/opensafemailinbrowser'
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-alarcon committed Sep 15, 2023
2 parents a250513 + 7795bdf commit 5bbca82
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ For other distributions please follow your specific steps.

```json
{
"urlMainWindow": "https://customurl.example/",
"urlsInternal": ["customurl.example"],
"urlsExternal": ["externalurls.example"],
"showWindowFrame": true
"urlMainWindow":"https://customurl.example/",
"deeplinkUrls":["customurl.example"],
"outlookUrls":["outlookurls.example"],
"externalUrls": ["externalurls.example"],
"showWindowFrame":true
}
```

Expand All @@ -88,11 +89,12 @@ Outlook.com account:
```json
{
"urlMainWindow": "https://outlook.live.com/mail",
"urlsInternal": ["outlook.com", "live.com"],
"urlsExternal": ["outlook.com", "live.com"]
"deeplinkUrls": ["outlook.com", "live.com"],
"outlookUrls": ["outlook.com", "live.com"]
}
```


### Architecture components

The main software architecture components and their versions are this:
Expand Down
40 changes: 26 additions & 14 deletions src/controller/mail-window-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ const settings = require("electron-settings");
const getClientFile = require("./client-injector");
const path = require("path");


let outlookUrl;
let deeplinkUrls;
let externalUrls;
let outlookUrls;
let showWindowFrame;
let $this;
Expand Down Expand Up @@ -47,10 +49,14 @@ class MailWindowController {
"outlook.office365.com",
"outlook.office.com",
];
externalUrls = settings.getSync('externalUrls') || [
'outlook.office.com/mail/safelink.html'
]
console.log("Loaded settings", {
outlookUrl: outlookUrl,
deeplinkUrls: deeplinkUrls,
outlookUrls: outlookUrls,
externalUrls: externalUrls,
});
}
init() {
Expand Down Expand Up @@ -195,20 +201,27 @@ class MailWindowController {

openInBrowser(e, url, frameName, disposition, options) {
console.log("Open in browser: " + url); //frameName,disposition,options)
if (new RegExp(deeplinkUrls.join("|")).test(url)) {
// Default action - if the user wants to open mail in a new window - let them.
//e.preventDefault()
console.log("Is deeplink");
options.webPreferences.affinity = "main-window";
} else if (new RegExp(outlookUrls.join("|")).test(url)) {
// Open calendar, contacts and tasks in the same window
e.preventDefault();
this.loadURL(url);
} else {
// Send everything else to the browser
e.preventDefault();
shell.openExternal(url);

if (!new RegExp(externalUrls.join("|")).test(url)) {
if (new RegExp(deeplinkUrls.join("|")).test(url)) {
// Default action - if the user wants to open mail in a new window - let them.
//e.preventDefault()
console.log("Is deeplink, open in main window");
options.webPreferences.affinity = "main-window";
return;
}
if (new RegExp(outlookUrls.join("|")).test(url)) {
// Open calendar, contacts and tasks in the same window
console.log("Is outlook URL, open in application");
e.preventDefault();
this.loadURL(url);
return;
}
}
// Send everything else to the browser
console.log("Is external URL, open in browser");
e.preventDefault();
shell.openExternal(url);
}

show() {
Expand Down Expand Up @@ -253,7 +266,6 @@ class MailWindowController {
);
}
//console.log(params)

for (const flag in params.editFlags) {
let actionLabel = flag.substring(3); //remove "can"
if (flag == "canSelectAll") {
Expand Down

0 comments on commit 5bbca82

Please sign in to comment.