Skip to content

Commit 1f5edb9

Browse files
authored
Merge pull request #139 from Zzombiee2361/master
Fix browser update notice
2 parents 8886977 + caf5dc1 commit 1f5edb9

File tree

3 files changed

+49
-28
lines changed

3 files changed

+49
-28
lines changed

package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "walc",
3-
"version": "0.1.12",
3+
"version": "0.2.1",
44
"description": "A WhatsApp Desktop client for linux systems. This is an unofficial client. Use https://web.whatsapp.com for official web client as official desktop client for linux does not exist.",
55
"main": "src/main.js",
66
"scripts": {
@@ -63,38 +63,38 @@
6363
"devDependencies": {
6464
"@mdi/js": "^5.9.55",
6565
"deepmerge": "^4.2.2",
66-
"electron": "^11.3.0",
67-
"electron-builder": "^22.4.0",
68-
"electron-devtools-installer": "^3.1.1",
66+
"electron": "^11.4.4",
67+
"electron-builder": "^22.10.5",
68+
"electron-devtools-installer": "^3.2.0",
6969
"electron-packager": "^14.2.1",
7070
"electron-rebuild": "^1.11.0",
71-
"laravel-mix": "^6.0.13",
72-
"postcss": "^8.2.8",
73-
"sass": "^1.32.8",
71+
"laravel-mix": "^6.0.18",
72+
"postcss": "^8.2.13",
73+
"sass": "^1.32.12",
7474
"sass-loader": "^11.0.1",
7575
"vue": "^2.5.17",
7676
"vue-loader": "^15.9.6",
7777
"vue-template-compiler": "^2.6.12",
78-
"vuetify": "^2.4.4",
78+
"vuetify": "^2.4.11",
7979
"vuetify-loader": "^1.7.2",
8080
"vuetifyjs-mix-extension": "0.0.20",
81-
"webpack": "^5.25.0"
81+
"webpack": "^5.36.2"
8282
},
8383
"homepage": "https://cstayyab.com/projects/walc",
8484
"dependencies": {
8585
"axios": "^0.21.1",
86-
"create-desktop-shortcuts": "^1.0.2",
86+
"create-desktop-shortcuts": "^1.4.0",
8787
"dot-prop": "^6.0.1",
88-
"electron-context-menu": "^2.4.0",
88+
"electron-context-menu": "^2.5.2",
8989
"electron-store": "^5.1.1",
90-
"electron-updater": "^4.2.5",
90+
"electron-updater": "^4.3.8",
9191
"electron-window-state": "^5.0.3",
9292
"get-port-sync": "^1.0.0",
9393
"lsb-release": "^0.1.0",
94-
"mime": "^2.4.5",
94+
"mime": "^2.5.2",
9595
"puppeteer-core": "^7.1.0",
9696
"puppeteer-in-electron": "^3.0.3",
9797
"vue-router": "^3.5.1",
98-
"whatsapp-web-electron.js": "^1.12.5"
98+
"whatsapp-web-electron.js": "^1.12.6"
9999
}
100100
}

src/Main/DashboardWindow.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@ module.exports = class DashboardWindow extends BrowserWindow {
3333
);
3434
this.setMenuBarVisibility(false);
3535

36-
// added timeout to prevent whatsapp being loaded to this window instead of main
37-
// hopefully no race condition bug later...
38-
setTimeout(() => {
39-
this.loadFile('public/index.html').then(() => {
40-
// just for debugging
41-
// this.show();
42-
// this.webContents.openDevTools();
43-
});
44-
}, 2000);
36+
this.loadFile('public/index.html').then(() => {
37+
// just for debugging
38+
// this.show();
39+
// this.webContents.openDevTools();
40+
});
4541

4642
this.isQuiting = false;
4743

src/Main/MainWindow.js

+30-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const { Client } = require('whatsapp-web-electron.js');
1111
// const getPortSync = require('get-port-sync');
1212

1313
const ICON_PATH = path.join(__dirname, '../icons/logo360x360.png');
14-
const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36';
14+
const userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36';
1515

1616
// notifications template
1717
const notifications = {
@@ -190,6 +190,24 @@ module.exports = class MainWindow extends BrowserWindow {
190190
this.notify('offline');
191191
});
192192

193+
let findID;
194+
this.webContents.on('found-in-page', (evt, result) => {
195+
if (result.requestId == findID) {
196+
if (result.matches > 0) {
197+
this.webContents.session.clearStorageData({ storages: ["serviceWorkers"] }).then(() => {
198+
this.webContents.reload();
199+
}).catch((err) => {
200+
console.log(err);
201+
});
202+
203+
}
204+
}
205+
});
206+
207+
this.webContents.on('did-finish-load', (evt) => {
208+
findID = this.webContents.findInPage('Update Google Chrome');
209+
});
210+
193211
settings.onDidChange('general.alwaysOnTop', (value) => {
194212
this.setAlwaysOnTop(value);
195213
});
@@ -201,15 +219,14 @@ module.exports = class MainWindow extends BrowserWindow {
201219

202220
async initWhatsapp() {
203221
this.loadURL('about:blank', { userAgent }).then(async () => {
204-
console.log('Initializing');
205222
const pieBrowser = await pie.connect(app, puppeteer);
206223

207-
console.log('Creating client');
208-
this.whatsapp = new Client(pieBrowser);
224+
console.log('Creating whatsapp client');
225+
this.whatsapp = new Client(pieBrowser, this);
209226
this.whatsappReady = false;
210227

211228
this.whatsapp.on('ready', () => {
212-
console.log('whatsapp-web.js ready');
229+
console.log('Whatsapp client ready');
213230
this.whatsappReady = true;
214231
this.webContents.send('ready', this._id);
215232
this.emit('ready');
@@ -238,6 +255,14 @@ module.exports = class MainWindow extends BrowserWindow {
238255
}
239256
});
240257

258+
this.whatsapp.on('disconnected', (reason) => {
259+
console.log(`\nWarning! Client disconnected. Reason: ${reason}\n`);
260+
this.whatsapp.removeAllListeners();
261+
delete this.whatsapp;
262+
// FIXME: for some reason web.whatsapp.com failed to load without the delay
263+
setTimeout(() => this.initWhatsapp(), 2000);
264+
});
265+
241266
this.whatsapp.initialize();
242267
});
243268
}

0 commit comments

Comments
 (0)