From a55b0fddd5c8559391bd853d5b93c0408756dec1 Mon Sep 17 00:00:00 2001 From: Tzikas Date: Wed, 28 Jul 2021 00:36:58 -0400 Subject: [PATCH] ohboy --- frontend/src/CowBell.js | 126 +++++++++++++++++------------ frontend/src/components/Chat.js | 2 +- frontend/src/components/SideBar.js | 2 +- main.js | 16 +++- package.json | 2 +- 5 files changed, 92 insertions(+), 56 deletions(-) diff --git a/frontend/src/CowBell.js b/frontend/src/CowBell.js index d56e9de..b26a76e 100644 --- a/frontend/src/CowBell.js +++ b/frontend/src/CowBell.js @@ -251,10 +251,10 @@ const CowBell = ({ children }) => { //New Room - Message everyone except you if (post.messageIds.length === 0) { - // console.log('newRoom', last?.userId?.name, last?.message, last?.userId?.avatar) - // setTimeout(() => { + console.log('newRoom', last?.userId?.name, last?.message, last?.userId?.avatar) + // setTimeout(() => { return notify(`🏡 ${post?.user?.name}`, post?.message, post?.user?.avatar, `/chat/${post._id}`) ///() => history.push(`/chat/${post._id}`) - // }, 2000) + // }, 2500) } @@ -536,6 +536,76 @@ const CowBell = ({ children }) => { // // (x) => (x.active && x.activeUsers.length) || x.id == 'lobby' || x.isLobby // ) + function notify(title, message, icon, redirect) { + + console.log("notify puppy dreams", redirect); + + // window.jitsiNodeAPI.ipc.send('notification-clicked', { redirect }) + + // window.open("google.com", "_blank"); + // Let's check if the browser supports notifications + if (!("Notification" in window)) { + alert("This browser does not support desktop notification"); + } + + // Let's check whether notification permissions have already been granted + else if (Notification.permission === "granted") { + // If it's okay let's create a notification + var options = { + body: message, + // icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png', + //icon: 'https://images.vexels.com/media/users/3/185580/isolated/preview/4481c0a89970cd7107424bb018900f2a-cool-hipster-pineapple-by-vexels.png' + icon: icon?.replace('svg', 'png'),//`https://avatars.dicebear.com/4.5/api/avataaars/0.33511928838302496.png` + silent: true + } + let audio = new Audio('../resources/cowbell.wav') + audio.volume = 0.5; + setTimeout(() => audio.play(), 1000) + + + var notification = new Notification(title, options); + + + + console.log(remote, win) + console.log(win.isVisible(), ' visible?>') + // console.log(win.hide) + // console.log(win.isMinimized) + // console.log(win.isHidden) + + + notification.onclick = () => { + // win.show() + // win.maximize() + if (!win.isVisible()) { + win.restore() + // win.show() + } + history.push(redirect) + // window.jitsiNodeAPI.ipc.send('notification-clicked', { redirect }) + } + + + + + } + + // Otherwise, we need to ask the user for permission + else if (Notification.permission !== "denied") { + Notification.requestPermission().then(function (permission) { + // If the user accepts, let's create a notification + if (permission === "granted") { + var notification = new Notification(message); + + } + }); + } + + // At last, if the user has denied notifications, and you + // want to be respectful there is no need to bother them any more. + } + + const [littleVideo, setLittleVideo] = useState(false) @@ -721,6 +791,9 @@ const CowBell = ({ children }) => { ) } + + + export default function CowBellWithRouter(props) { return ( @@ -731,51 +804,4 @@ export default function CowBellWithRouter(props) { -function notify(title, message, icon, redirect) { - - console.log("notify puppy dreams", redirect); - - // window.jitsiNodeAPI.ipc.send('notification-clicked', { redirect }) - - // window.open("google.com", "_blank"); - // Let's check if the browser supports notifications - if (!("Notification" in window)) { - alert("This browser does not support desktop notification"); - } - - // Let's check whether notification permissions have already been granted - else if (Notification.permission === "granted") { - // If it's okay let's create a notification - var options = { - body: message, - // icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png', - //icon: 'https://images.vexels.com/media/users/3/185580/isolated/preview/4481c0a89970cd7107424bb018900f2a-cool-hipster-pineapple-by-vexels.png' - icon: icon?.replace('svg', 'png'),//`https://avatars.dicebear.com/4.5/api/avataaars/0.33511928838302496.png` - silent: true - } - let audio = new Audio('../resources/cowbell.wav') - audio.volume = 0.5; - setTimeout(() => audio.play(), 1000) - - var notification = new Notification(title, options); - //notification.onclick = () => history.push(redirect) - - notification.onclick = () => window.jitsiNodeAPI.ipc.send('notification-clicked', { redirect }) - - } - - // Otherwise, we need to ask the user for permission - else if (Notification.permission !== "denied") { - Notification.requestPermission().then(function (permission) { - // If the user accepts, let's create a notification - if (permission === "granted") { - var notification = new Notification(message); - - } - }); - } - - // At last, if the user has denied notifications, and you - // want to be respectful there is no need to bother them any more. -} diff --git a/frontend/src/components/Chat.js b/frontend/src/components/Chat.js index 619f090..b62809f 100644 --- a/frontend/src/components/Chat.js +++ b/frontend/src/components/Chat.js @@ -285,7 +285,7 @@ function Chat(props) { - {console.log(channel?.user?._id, user?._id, !channel?.userChannel, channel, 'english chunnel')} + {/* {console.log(channel?.user?._id, user?._id, !channel?.userChannel, channel, 'english chunnel')} */}

This is the beginning of your chat history...

{channel?.user?._id == user?._id && !channel?.userChannel ? : null}

diff --git a/frontend/src/components/SideBar.js b/frontend/src/components/SideBar.js index d910d45..799c1a3 100644 --- a/frontend/src/components/SideBar.js +++ b/frontend/src/components/SideBar.js @@ -33,7 +33,7 @@ const Room = ({ room, id }) => { } }, 0) - console.log('dracula', pathname.split('/').pop() === room._id) + // console.log('dracula', pathname.split('/').pop() === room._id) if (pathname.split('/').pop() === room._id) { count = 0 } diff --git a/main.js b/main.js index 0944de2..fb1bd5d 100644 --- a/main.js +++ b/main.js @@ -206,10 +206,12 @@ function createJitsiMeetWindow(event, redirectUrl) { console.log(basePath, 'basePathbasePath', redirectUrl) + + //file:///Users/niko/Documents/Code/Q-Jitsi-Electron/build/index.html#/chat/60ff2980a76ffd0cdb131291 // URL for index.html which will be our entry point. let indexURL = URL.format({ - pathname: path.resolve(basePath, './build/index.html?chat=60ff2980a76ffd0cdb131292'), + pathname: path.resolve(basePath, './build/index.html'), protocol: 'file:', slashes: true }); @@ -497,12 +499,17 @@ app.on('second-instance', (event, commandLine) => { app.on('window-all-closed', () => { // Don't quit the application on macOS. - // console.log(app, ' all closeds') + console.log(app, ' all closeds') console.log('process.platform', process.platform) if (process.platform !== 'darwin') { app.quit(); } }); + +app.on('before-quit', () => { console.log('before quit') }) + + +app.on('will-quit', () => { console.log('will quit') }) // app.on('window-all-closed', () => { // app.dock.hide() // for macOS // // use same logic for other OSes you want @@ -677,7 +684,10 @@ ipcMain.on('notification-clicked', function (event, data) { // app.open() // event.sender.loadURL(data.redirect) // mainWindow.loadURL(indexURL); - createJitsiMeetWindow(event, data.redirect) + console.log('main window', mainWindow) + if (!mainWindow) { + createJitsiMeetWindow(event, data.redirect) + } // const win = new BrowserWindow({ width: 800, height: 1500 }) // win.loadURL('file:///Users/niko/Documents/Code/Q-Jitsi-Electron/build/index.html#/chat/60ff2980a76ffd0cdb131291') diff --git a/package.json b/package.json index 0c1c952..74e3804 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "CowBellClub", - "version": "1.9.1", + "version": "1.9.2", "description": "Electron application for Cowbell Club", "main": "./build/main.js", "productName": "CowbellClub",