From c3b703f3eeaeb92133a8b289349c0e57c1de5de1 Mon Sep 17 00:00:00 2001 From: Tzikas Date: Tue, 20 Jul 2021 17:40:28 -0400 Subject: [PATCH] minimize maxomize --- frontend/src/CowBell.js | 72 +++++++++++++++++- frontend/src/components/NavBar.js | 23 +----- frontend/src/index.css | 120 +++++++++++++++++++++++++++++- main.js | 2 +- package.json | 2 +- 5 files changed, 192 insertions(+), 27 deletions(-) diff --git a/frontend/src/CowBell.js b/frontend/src/CowBell.js index 2838517..d3c0bbd 100644 --- a/frontend/src/CowBell.js +++ b/frontend/src/CowBell.js @@ -42,8 +42,12 @@ import io from 'socket.io-client' //Make connection to server just once on page load. import baseURL from './api/config' +const remote = require('electron').remote; +const win = remote.getCurrentWindow(); +console.log(remote, win) + // TODO: Convert this into a reusable useSocket or something @@ -209,8 +213,9 @@ const CowBell = ({ children }) => { return } - // console.log('post:', post, ' kiwi') - + console.log('post:', post, ' kiwi') + const [yourBrowserWindow] = remote.BrowserWindow.getAllWindows(); + console.log(yourBrowserWindow.isFocused(), ' in focused'); _setPosts(function (posts) { let newPosts = { ...posts } @@ -232,7 +237,11 @@ const CowBell = ({ children }) => { // console.log(pathname, last?.postId, 'pathname', pathname.split('/')[2], pathname.split('/')[2] === last?.postId, window.location) //You're in that chat room so don't notify - if (window.location.hash.split('/').pop() === last?.postId) { + + + + if (window.location.hash.split('/').pop() === last?.postId && yourBrowserWindow.isFocused()) { + console.log('YOURE IN THE CHAT ROOM') return } // console.log(post.event, 'event') @@ -554,6 +563,63 @@ const CowBell = ({ children }) => { return user ? ( +
+ +
+
+ { + console.log(process.platform) + process.platform === "darwin" ? win.hide() : win.minimize() + }} className="closebutton" href="#">x + +
+
+ { + win.minimize() + }} className="minimizebutton" href="#"> + +
+
+ { + console.log(win.fullScreen) + win.setFullScreen(!win.fullScreen) + }} className="zoombutton" href="#">+ + +
+
+ + + {/* + + + + + + + + + */} +
diff --git a/frontend/src/components/NavBar.js b/frontend/src/components/NavBar.js index 3d78ece..9596c33 100644 --- a/frontend/src/components/NavBar.js +++ b/frontend/src/components/NavBar.js @@ -5,12 +5,8 @@ import Search from './Search' import TheContext from '../TheContext' import SideBar from './SideBar' import { version } from '../../../package.json' -console.log(version, ' version number: '); -const remote = require('electron').remote; +console.log(version, ' version number: ', process); - -const win = remote.getCurrentWindow(); -console.log(remote, win) // sound.play(path.join(__dirname, "resources/cowbell.wav")) @@ -51,22 +47,7 @@ export function NavBar({ user }) { // console.log('chat room ==> ', pathname.split('/').pop() === lobby_id ? 'lobby' : pathname) return (<> -
- - - - -
+