Skip to content

Commit

Permalink
ohboy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzikas committed Jul 28, 2021
1 parent 7156ec2 commit a55b0fd
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 56 deletions.
126 changes: 76 additions & 50 deletions frontend/src/CowBell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -721,6 +791,9 @@ const CowBell = ({ children }) => {
)
}




export default function CowBellWithRouter(props) {
return (
<HashRouter>
Expand All @@ -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.
}

2 changes: 1 addition & 1 deletion frontend/src/components/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')} */}
<p>This is the beginning of your chat history...</p>
<p>{channel?.user?._id == user?._id && !channel?.userChannel ? <button onClick={closeRoom} className="remove">Close Room</button> : null}</p>
</li>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/SideBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 13 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit a55b0fd

Please sign in to comment.