Skip to content

Commit

Permalink
v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Jan 18, 2020
1 parent 66b71f0 commit 58c8a46
Show file tree
Hide file tree
Showing 4 changed files with 1,506 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ if (!singleInstanceLock) {
},
// Hides main window until it is ready to show
show: false,
minHeight: 600,
});

mainWindow.setBounds(windowState.get('bounds'));
Expand Down Expand Up @@ -649,6 +650,8 @@ if (!singleInstanceLock) {
// Set global settings whenever they are changed
ipcMain.on('settings-changed', e => setGlobalSettings());

ipcMain.on('new-message', (e, m) => mainWindow.webContents.send('new-message', m));

// Message Indicator
ipcMain.on('message-indicator', (e, i) => {
if (process.platform === 'darwin') {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "altus",
"version": "3.3.0",
"version": "3.4.0",
"description": "Electron-based desktop wrapper for WhatsApp Web",
"homepage": "https://shadythgod.github.io/altus",
"repository": {
Expand Down
35 changes: 29 additions & 6 deletions src/windows/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ const customTitlebar = require('custom-electron-titlebar');

// Import extra electron modules
const {
process
process,
BrowserWindow
} = require('electron').remote;
const {
ipcRenderer
ipcRenderer,
} = require('electron');

// Import electron store module for settings
Expand Down Expand Up @@ -415,12 +416,16 @@ function toggleNotifications(whatsAppElement, setting, firstStart) {
if (firstStart) {
whatsapp.addEventListener('dom-ready', () => {
if (!setting) {
whatsapp.executeJavaScript(`window.Notification = ''`);
whatsapp.executeJavaScript(`window.NotificationSetting = false`);
} else {
whatsapp.executeJavaScript(`window.NotificationSetting = true`);
}
});
} else {
if (!setting) {
whatsapp.executeJavaScript(`window.Notification = ''`);
whatsapp.executeJavaScript(`window.NotificationSetting = false`);
} else {
whatsapp.executeJavaScript(`window.NotificationSetting = true`);
}
}
}
Expand Down Expand Up @@ -458,7 +463,7 @@ ipcRenderer.on('themes-changed', e => {
// IPC event of message indicator
ipcRenderer.on('message-indicator', (e, i) => {
if (i > 0 && i !== undefined && i !== null) {
ipcRenderer.sendSync('update-badge', '·');
ipcRenderer.sendSync('update-badge', i);
} else {
ipcRenderer.sendSync('update-badge', '');
}
Expand Down Expand Up @@ -515,4 +520,22 @@ function getActiveTab() {
tab: activeTab,
whatsapp: activeWhatsApp
}
}
}

ipcRenderer.on('new-message', (e, m) => {
if (m.message && m.message.length > 0) {
let chat = m.message[0];
let name = chat.chat.name;
let wID = m.wID;
let options = {
body: chat.body,
icon: chat.sender.profilePicThumbObj.eurl,
}
let _notification = new Notification(name, options);
_notification.onclick = e => {
BrowserWindow.getAllWindows()[0].focus();
let webview = document.querySelector(`#${wID}`);
webview.send('open-chat', chat.chatId._serialized);
};
}
});
Loading

0 comments on commit 58c8a46

Please sign in to comment.