Skip to content

Commit

Permalink
conflict fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
neyaoz committed Oct 27, 2015
2 parents e7a057a + b614d36 commit c6bd6ee
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,48 @@

global.whatsApp = {
init: function() {
this.createMenu();
this.createTray();

this.clearCache();
this.openWindow();
whatsApp.createMenu();
whatsApp.createTray();

whatsApp.clearCache();
whatsApp.openWindow();

app.on('window-all-closed', onlyWin(function() {
app.quit();
}));
},
createMenu: function() {
this.menu =
whatsApp.menu =
appMenu.buildFromTemplate(require('./menu'));
appMenu.setApplicationMenu(this.menu);
appMenu.setApplicationMenu(whatsApp.menu);
},
createTray: function() {
this.tray = new AppTray(__dirname + '/assets/img/trayTemplate.png');
whatsApp.tray = new AppTray(__dirname + '/assets/img/trayTemplate.png');

this.tray.on('clicked', function() {
this.window.show();
}.bind(this));
whatsApp.tray.on('clicked', function() {
whatsApp.window.show();
});

this.tray.setToolTip('WhatsApp Desktop');
whatsApp.tray.setToolTip('WhatsApp Desktop');
},
clearCache: function() {
try{
fileSystem.unlinkSync(app.getPath('appData') + '/Application Cache/Index');
}catch(e){}
},
openWindow: function() {
this.window = new BrowserWindow(
whatsApp.window = new BrowserWindow(
{
'width': 1000,
'height': 720,
'title': '',
'node-integration': false
}
);
this.window.loadUrl('https://web.whatsapp.com', {
whatsApp.window.loadUrl('https://web.whatsapp.com', {
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.52 Safari/537.36'
});
this.window.show();
whatsApp.window.show();

this.window.on('page-title-updated', onlyOSX(function(event, title) {
whatsApp.window.on('page-title-updated', onlyOSX(function(event, title) {
var count = title.match(/\((\d+)\)/);
count = count ? count[1] : '';

Expand All @@ -76,21 +74,30 @@
}
}));

this.window.webContents.on("new-window", function(e, url){
whatsApp.window.webContents.on("new-window", function(e, url){
require('shell').openExternal(url);
e.preventDefault();
});

this.window.on('close', function(e){
if (process.platform === 'darwin' && this.window.forceClose === false) {

whatsApp.window.on('close', onlyOSX(function(e) {
if (whatsApp.window.forceClose !== true) {
e.preventDefault();
this.window.hide();
whatsApp.window.hide();
}
}.bind(this));
}));

app.on('before-quit', function() {
if (this.window) this.window.forceClose = true;
}.bind(this));
app.on('before-quit', onlyOSX(function() {
whatsApp.window.forceClose = true
}));

app.on('activate-with-no-open-windows', onlyOSX(function() {
whatsApp.window.show();
}));

app.on('window-all-closed', onlyWin(function() {
app.quit();
}));
}
};

Expand Down

0 comments on commit c6bd6ee

Please sign in to comment.