Skip to content

Commit

Permalink
Merge pull request #580 from Araxeus/discord-timeout-time-prompt
Browse files Browse the repository at this point in the history
discord set inactivity timeout prompt
  • Loading branch information
th-ch authored Feb 9, 2022
2 parents ed15ee9 + 8268b18 commit 05b877b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"async-mutex": "^0.3.2",
"browser-id3-writer": "^4.4.0",
"chokidar": "^3.5.3",
"custom-electron-prompt": "^1.4.0",
"custom-electron-prompt": "^1.4.1",
"custom-electron-titlebar": "^3.2.10",
"discord-rpc": "^4.0.1",
"electron-better-web-request": "^1.0.1",
Expand Down
26 changes: 22 additions & 4 deletions plugins/discord/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const prompt = require("custom-electron-prompt");

const { setMenuOptions } = require("../../config/plugins");
const { edit } = require("../../config");
const promptOptions = require("../../providers/prompt-options");
const { clear, connect, registerRefresh, isConnected } = require("./back");

let hasRegisterred = false;
Expand Down Expand Up @@ -39,9 +41,25 @@ module.exports = (win, options, refreshMenu) => {
},
},
{
label: "Set timeout time in config",
// open config.json
click: edit,
label: "Set inactivity timeout",
click: () => setInactivityTimeout(win, options),
},
];
};

async function setInactivityTimeout(win, options) {
let output = await prompt({
title: 'Set Inactivity Timeout',
label: 'Enter inactivity timeout in seconds:',
value: Math.round((options.activityTimoutTime ?? 0) / 1e3),
type: "counter",
counterOptions: { minimum: 0, multiFire: true },
width: 450,
...promptOptions()
}, win)

if (output) {
options.activityTimoutTime = Math.round(output * 1e3);
setMenuOptions("discord", options);
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2725,10 +2725,10 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"

custom-electron-prompt@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.4.0.tgz#04d261372807b87ec07ed12e990306d5debd5667"
integrity sha512-tqDa3yDILVI3xxwNRW1m2fyQgdMYtFcnl1d3uMx8Tt6sQ9zG+Y4n/ie4VbttQaq7dJvFCu9K3JX65K8hfaSf1g==
custom-electron-prompt@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/custom-electron-prompt/-/custom-electron-prompt-1.4.1.tgz#79adc3d5cd9a372e5dfe43b21de70f0fe7d1c2f7"
integrity sha512-bR6JhEusBxKnooXfFFlIIUhDbF23eaDhaYwvqcw3ZTcdEzzJew63+ilwhIwD7flRAO+sCroaLwP495VBexHg/A==

custom-electron-titlebar@^3.2.10:
version "3.2.10"
Expand Down

0 comments on commit 05b877b

Please sign in to comment.