From d62ec24da8797ad667e6ba869246b728ed275a48 Mon Sep 17 00:00:00 2001 From: chinmaydixit20 <55713205+chinmaydixit20@users.noreply.github.com> Date: Mon, 6 Jul 2020 19:09:13 +0530 Subject: [PATCH] Active users working --- backend/server.js | 1 + public/electron.js | 45 ++++++++++++++++++++++++++++++++++++++++++++- public/index.html | 11 ----------- public/js/index.js | 2 +- public/js/main.js | 4 +++- 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/backend/server.js b/backend/server.js index 2d9fb42..95d9276 100644 --- a/backend/server.js +++ b/backend/server.js @@ -46,6 +46,7 @@ io.on('connection', socket => { socket.on('switch_room', (room) => { const oldRoom = currentUser(socket.id).room; + console.log(oldRoom); const u = userSwitch(socket.id, room); socket.leaveAll(); socket.join(u.room); diff --git a/public/electron.js b/public/electron.js index c4ba136..e4dc8ac 100644 --- a/public/electron.js +++ b/public/electron.js @@ -3,6 +3,7 @@ const path = require('path'); const url = require('url'); const { app, BrowserWindow, ipcMain } = electron; const isDev = require('electron-is-dev'); +const { Menu, globalShortcut } = require('electron'); let mainWindow; @@ -16,6 +17,10 @@ function createWindow() { }); mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, 'index.html')}`); mainWindow.on('closed', () => mainWindow = null); + globalShortcut.register('CmdOrCtrl+Q', () => app.quit()); + + const menu = Menu.buildFromTemplate(menuTemplate); + Menu.setApplicationMenu(menu); } ipcMain.on('userLogin', (e, user) => { @@ -36,4 +41,42 @@ app.on('activate', () => { if (mainWindow === null) { createWindow(); } -}); \ No newline at end of file +}); + +const menuTemplate = [ + { + label: 'Chat', + submenu: [ + { + label: 'Quit', + click() { + app.quit(); + } + }, + { + type: 'separator' + }, + { + role: 'reload' + } + ] + } +] + +if(isDev) { + menuTemplate.push({ + label: 'DevTools', + submenu: [ + { + label: 'DevTools', + click(item, focusedWindow) { + focusedWindow.toggleDevTools(); + } + } + ] + }) +} + +if(process.platform == 'darwin') { + menuTemplate.unshift(); +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 97d9a92..3e9b75b 100644 --- a/public/index.html +++ b/public/index.html @@ -41,17 +41,6 @@