Skip to content

Commit

Permalink
✨ BUG report button on context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerluiz committed Mar 21, 2020
1 parent 80a89c4 commit 77aa912
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
21 changes: 17 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const {
ipcMain,
systemPreferences,
nativeTheme,
screen
screen,
shell
} = require("electron");
const path = require("path");
const fs = require("fs");
Expand All @@ -20,7 +21,6 @@ const { statusBarMenu } = require("./providers/templateProvider");
const { calcYTViewSize } = require("./utils/calcYTViewSize");
const { isWindows, isMac } = require("./utils/systemInfo");
const isDev = require("electron-is-dev");
const isOnline = require("is-online");
const ClipboardWatcher = require("electron-clipboard-watcher");
const {
companionUrl,
Expand Down Expand Up @@ -69,8 +69,6 @@ let infoPlayerInterval;
let customThemeCSSKey;
let lastTrackId;
let doublePressPlayPause;
let lastConnectionStatusIsOnline = false;
let hasLoadedUrl;
let isClipboardWatcherRunning = false;
let clipboardWatcher = null;

Expand Down Expand Up @@ -823,6 +821,21 @@ function createWindow() {
console.log(message);
});

ipcMain.on("bug-report", (event, message) => {
var os_platform = process.platform || "-";
var os_arch = process.arch || "-";
var os_system_version = process.getSystemVersion() || "-";

var node_version = process.versions["node"] || "-";

var ytmdesktop_version = process.env["npm_package_version"] || "-";

var template = `%23%23%23%23 Problem %0A%23%23%23%23%23%23 (Describe the problem here) %0A%23%23%23%23 Environment %0A * YTMDesktop: ${ytmdesktop_version} %0A * Platform: ${os_platform} %0A * Arch: ${os_arch} %0A * Version: ${os_system_version} %0A * Node: ${node_version}`;
shell.openExternal(
`https://github.com/ytmdesktop/ytmdesktop/issues/new?title=Issue%20title&body=${template}`
);
});

function loadCustomTheme() {
if (settingsProvider.get("settings-custom-theme")) {
if (fs.existsSync(themePath)) {
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"electron-store": "^5.1.0",
"electron-updater": "^4.2.0",
"i18n": "^0.8.5",
"is-online": "^8.2.1",
"js-base64": "^2.5.1",
"materialize-css": "^1.0.0",
"node-vibrant": "^3.1.5",
Expand Down
11 changes: 10 additions & 1 deletion utils/injectControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ function createMenu() {
.btn-disabled {
color: #000 !important;
}
.text-red {
color: red !important;
}
`);

var menu = `<a id="ytmd-menu-lyrics"><i class="material-icons">music_note</i></a> <a id="ytmd-menu-miniplayer"><i class="material-icons">picture_in_picture_alt</i></a> `;
var menu = `<a id="ytmd-menu-lyrics"><i class="material-icons">music_note</i></a> <a id="ytmd-menu-miniplayer"><i class="material-icons">picture_in_picture_alt</i></a> <a id="ytmd-menu-bug-report"><i class="material-icons text-red">bug_report</i></a>`;

content.executeJavaScript(`
var menuDiv = document.createElement("div");
Expand All @@ -101,6 +105,7 @@ function createMenu() {
var buttonOpenCompanion = document.getElementById('ytmd-menu-companion-server');
var buttonOpenMiniplayer = document.getElementById('ytmd-menu-miniplayer');
var buttonOpenLyrics = document.getElementById('ytmd-menu-lyrics');
var buttonOpenBugReport = document.getElementById('ytmd-menu-bug-report');
var buttonPageOpenMiniplayer = document.getElementsByClassName('player-minimize-button ytmusic-player')[0];
document.addEventListener('contextmenu', function (e) {
Expand Down Expand Up @@ -132,6 +137,10 @@ function createMenu() {
buttonPageOpenMiniplayer.addEventListener('click', function(e) { /* Temporary fix */ document.getElementsByClassName('player-maximize-button ytmusic-player')[0].click(); ipcRenderer.send('show-miniplayer'); } );
}
if (buttonOpenBugReport) {
buttonOpenBugReport.addEventListener('click', function() { ipcRenderer.send('bug-report'); } );
}
function showMenu(x, y) {
menuElement.top = y + "px";
menuElement.left = x + "px";
Expand Down

0 comments on commit 77aa912

Please sign in to comment.