Skip to content

Commit

Permalink
Fixed a bug & notifies when PC goes offline
Browse files Browse the repository at this point in the history
  • Loading branch information
cstayyab committed May 4, 2020
1 parent 46aa6ae commit 76d5467
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, session, Menu, dialog, Tray, remote, ipcMain, nativeImage } = require('electron');
const { app, BrowserWindow, session, Menu, dialog, Tray, remote, ipcMain, nativeImage, Notification } = require('electron');
const { autoUpdater } = require("electron-updater");
const { Client } = require('./WhatsBot/index');
const pie = require("puppeteer-in-electron");
Expand Down Expand Up @@ -273,6 +273,11 @@ function loadWA() {
console.log(err);
});

}).catch((err) => {
isConnected = false
win.loadFile('offline.html');
delete botClient;
liveCheck()
});

win.on('page-title-updated', (evt) => {
Expand Down Expand Up @@ -308,10 +313,10 @@ function liveCheck() {
if (err) {
if (isConnected) {
win.loadFile('offline.html');
new Notification({"title": "WALC cannot Access WhatsApp Server.", "body": "Please check your connection.", "silent": false, "icon": "icons/logo256x256.png"}).show()
delete botClient;
}
isConnected = false;

} else {
if (isConnected) {

Expand Down

0 comments on commit 76d5467

Please sign in to comment.