Skip to content

Commit

Permalink
Removed Preferences - didn't work anyway
Browse files Browse the repository at this point in the history
 - With Prefernce gone - all React & mobx wasn't needed (.app now builds and loads faster)
 - Added eslist vscode settings to stop "constant" warnings

Fixed notification onclick errors. Closes uffou#6
  • Loading branch information
mountainash committed Feb 16, 2020
1 parent f4d95b3 commit 4349682
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 358 deletions.
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"javascript.validate.enable": false
"javascript.validate.enable": false,
"eslint.options": {
"useEslintrc": false,
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"es6": true
}
}
}
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
{
"name": "mixcloud-play",
"version": "0.9.3",
"description": "The desktop client MixCloud",
"version": "0.9.4",
"description": "The MixCloud desktop client",
"keywords": [
"music",
"osx",
"macOS",
"mixcloud",
"wrapper",
"media keys"
],
"author": {
"name": "Codemotion Ltd."
},
Expand All @@ -17,6 +25,9 @@
"type": "git",
"url": "[email protected]:uffou/MixCloud-Play.git"
},
"bugs": {
"url": "https://github.com/uffou/MixCloud-Play/issues"
},
"license": "UNLICENSED",
"scripts": {
"start": "electron .",
Expand Down Expand Up @@ -48,16 +59,11 @@
"@babel/plugin-proposal-decorators": "^7.0.0-rc.3",
"@babel/plugin-proposal-function-bind": "^7.0.0-rc.3",
"@babel/preset-env": "^7.0.0-rc.3",
"@babel/preset-react": "^7.0.0-rc.3",
"babel-loader": "^8.0.0-beta.6",
"copy-webpack-plugin": "^4.5.2",
"electron": "2.0.8",
"electron-builder": "20.28.2",
"electron-ipc-log": "^3.0.1",
"mobx": "5.0.5",
"mobx-react": "5.2.5",
"react": "16.4.2",
"react-dom": "16.4.2",
"rimraf": "^2.6.2",
"webpack": "^4.17.1",
"webpack-cli": "^3.1.0"
Expand All @@ -66,4 +72,4 @@
"electron-context-menu": "0.10.0",
"electron-store": "2.0.0"
}
}
}
79 changes: 32 additions & 47 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,8 @@ const ConfigStore = require(`electron-store`);

const menuTemplate = require(`./menu`);

var preferencesWindow;

function openPreferences() {
preferencesWindow = new BrowserWindow({
width: 400,
height: 400,
title: 'Preferences'
})
contextMenu({ window: preferencesWindow });

preferencesWindow.loadURL(`file://${__dirname}/preferences/index.html`)

preferencesWindow.on('close', () => {
preferencesWindow = undefined;
});

//preferencesWindow.webContents.openDevTools();
}

let mainWindow;
let tray
let tray;

const toggleWindow = () => {
if (mainWindow.isVisible()) {
Expand All @@ -55,11 +36,10 @@ const createTray = () => {
});
};

menuTemplate.setPreferencesClickHandler(openPreferences);
menuTemplate.setDashboardClickHandler(() => {
mainWindow.webContents.send('goToDashboard');
})
const menu = Menu.buildFromTemplate(menuTemplate)
const menu = Menu.buildFromTemplate(menuTemplate);

function closeHandler(event) {
event.preventDefault();
Expand All @@ -68,29 +48,34 @@ function closeHandler(event) {
}

app.on('web-contents-created', (event, contents) => {
if (contents.getType() === 'webview') {
contents.on('new-window', (event, url) => {
shell.openExternal(url)
event.preventDefault()
})
}
})
if (contents.getType() === 'webview') {
contents.on('new-window', (event, url) => {
shell.openExternal(url)
event.preventDefault()
});
}
});

app.on('ready', () => {
createTray();
Menu.setApplicationMenu(menu);

mainWindow = new BrowserWindow({
titleBarStyle: 'hiddenInset',
titleBarStyle: 'hiddenInset',
width: 1100,
minWidth: 768,
height: 800,
minHeight: 400,
minHeight: 400,
webPreferences: {
// preload: 'preload.js', //
nodeIntegration: true //TODO turn this off
}
});

mainWindow.webContents.loadFile(path.join(__dirname, 'index.html'))
mainWindow.loadFile(path.join(__dirname, 'index.html'));
//mainWindow.loadURL(path.join('file://', __dirname, '/index.html'))

// mainWindow.webContents.openDevTools();
//mainWindow.openDevTools();

mainWindow.on('focus', () => {
// app.dock.setBadge("");
Expand Down Expand Up @@ -140,7 +125,7 @@ app.on('ready', () => {
});

app.on('activate', () => {
!preferencesWindow && mainWindow && mainWindow.show();
mainWindow && mainWindow.show();
});

app.on('before-quit', () => {
Expand All @@ -158,8 +143,9 @@ ipcMain.on('notification', (_event, notificationIndex, subtitle) => {
subtitle,
silent: true
});
notification.on('click', () => {
mainWindow.webContents.send('notificationClicked', notificationIndex);
notification.on('click', (e) => {
console.log('notificationClicked - click', e);
mainWindow.webContents.send('notificationClicked', e);
mainWindow.show();
});
notification.show();
Expand All @@ -177,8 +163,9 @@ ipcMain.on('handlePause', (_, track) => {
subtitle: track,
silent: true
});
notification.on('click', () => {
mainWindow.webContents.send('notificationClicked', notificationIndex);
notification.on('click', (e) => {
console.log('notificationClicked - pause', e);
mainWindow.webContents.send('notificationClicked', e);
mainWindow.show();
});
notification.show();
Expand All @@ -197,8 +184,9 @@ ipcMain.on('nowPlaying', (_, nowPlaying, title, subtitle) => {
subtitle: subtitle,
silent: true
});
notification.on('click', () => {
mainWindow.webContents.send('notificationClicked', notificationIndex);
notification.on('click', (e) => {
console.log('notificationClicked - nowPlaying', e);
mainWindow.webContents.send('notificationClicked', e);
mainWindow.show();
});
notification.show();
Expand All @@ -216,16 +204,13 @@ ipcMain.on('handlePlay', (_, track) => {
subtitle: track,
silent: true
});
notification.on('click', () => {
mainWindow.webContents.send('notificationClicked', notificationIndex);
notification.on('click', (e) => {
console.log('notificationClicked - handlePlay', e);
mainWindow.webContents.send('notificationClicked', e);
mainWindow.show();
});
notification.show();
setTimeout(() => {
notification.close();
}, 7000);
});

ipcMain.on('updatedPreferences', () => {
mainWindow.webContents.send('updatedPreferences');
})
});
35 changes: 6 additions & 29 deletions src/menu.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
const preferencesItem = {
label: 'Preferences...',
accelerator: 'Command+,'
};

const dashboardItem = {
label: 'Dashboard'
};
Expand All @@ -16,8 +11,6 @@ const template = [
role: 'about'
},
{ type: 'separator' },
preferencesItem,
{ type: 'separator' },
{
role: 'services',
submenu: []
Expand All @@ -40,9 +33,7 @@ const template = [
}
]
},
{
role: 'editMenu'
},
{ role: 'editMenu' },
{
label: 'View',
submenu: [
Expand Down Expand Up @@ -86,29 +77,15 @@ const template = [
{
role: 'window',
submenu: [
{
role: 'close'
},
{
role: 'minimize'
},
{
role: 'zoom'
},
{
type: 'separator'
},
{
role: 'front'
}
{ role: 'close' },
{ role: 'minimize' },
{ role: 'zoom' },
{ type: 'separator' },
{ role: 'front' }
]
}
];

template.setPreferencesClickHandler = (handler) => {
preferencesItem.click = handler;
}

template.setDashboardClickHandler = (handler) => {
dashboardItem.click = handler;
}
Expand Down
29 changes: 0 additions & 29 deletions src/preferences/Main.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/preferences/SettingsStore.js

This file was deleted.

16 changes: 0 additions & 16 deletions src/preferences/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions src/preferences/renderer.js

This file was deleted.

Loading

0 comments on commit 4349682

Please sign in to comment.