Skip to content

Commit

Permalink
Added Rate & Review Option in Help Menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cstayyab committed May 20, 2020
1 parent f24f4e3 commit 29250ff
Showing 1 changed file with 46 additions and 5 deletions.
51 changes: 46 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,25 @@ const WhatsAppMenu = [{
await archiveAllChats();
menuItem.enabled = true;
}
}, {
label: "Mark All As Read",
sublabel: "Mark all chat as read",
click: async (menuItem, window, e) => {
menuItem.enabled = false;
await markAllChatsAsRead();
menuItem.enabled = true;
}
}, {
label: 'separator',
type: 'separator'
}, {
label: "Dark Mode",
sublabel: "Toggle Dark Mode",
type: 'checkbox',
checked: settings.get('darkMode.value'),
click: (menuItem, window, e) => {
settings.set('darkMode.value', menuItem.checked);
if(menuItem.checked) {
if (menuItem.checked) {
win.webContents.send("enableDarkMode");
} else {
win.webContents.send("disableDarkMode");
Expand Down Expand Up @@ -212,7 +223,7 @@ const settingsMenu = [{
checked: settings.get("autoHideMenuBar.value"),
click: (menuItem) => {
settings.set('autoHideMenuBar.value', menuItem.checked);
if(menuItem.checked) {
if (menuItem.checked) {
win.setMenuBarVisibility(false);
} else {
win.setMenuBarVisibility(true);
Expand Down Expand Up @@ -302,6 +313,12 @@ const helpMenu = [{
}, {
label: 'separator',
type: 'separator'
}, {
label: 'Rate && Review WALC',
sublabel: 'Help WALC grow by reviewing',
click: () => {
rateAndReviewWALC();
}
}, {
label: 'About WALC',
sublabel: 'See Version and Diagnostic Info.',
Expand Down Expand Up @@ -388,9 +405,9 @@ function loadWA() {
const menubar = Menu.buildFromTemplate(mainmenu);
Menu.setApplicationMenu(menubar);
win.setMenuBarVisibility(!settings.get('autoHideMenuBar.value'));

win.loadURL('https://web.whatsapp.com', { 'userAgent': userAgent }).then(async () => {
if(settings.get('darkMode.value')) {
if (settings.get('darkMode.value')) {
win.webContents.send("enableDarkMode");
} else {
win.webContents.send("disableDarkMode");
Expand Down Expand Up @@ -599,6 +616,23 @@ app.on('activate', () => {
}
});

/* Additional Functions */
function openInSnapStore() {
shell.openExternal("snap://walc");
}

function viewOnLinuxApps() {
shell.openExternal("https://www.linux-apps.com/p/1383431/");
}

function rateAndReviewWALC() {
if (isSNAP) {
openInSnapStore();
} else {
viewOnLinuxApps();
}
}

/* All functions related to WhatsBot */
async function archiveAllChats() {
currentNotify = new Notification({ "title": "Archive All Chats", "body": "Archiving all chats . . .", "silent": true, "icon": "icons/logo256x256.png" })
Expand All @@ -609,5 +643,12 @@ async function archiveAllChats() {
})
currentNotify.close();
new Notification({ "title": "Archive All Chats", "body": "All chats have been archived.", "silent": true, "icon": "icons/logo256x256.png" })


}

async function markAllChatsAsRead() {
chats = await botClient.getChats()
chats.forEach(async (chat) => {
await chat.sendSeen();
});
}

0 comments on commit 29250ff

Please sign in to comment.