Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
chaposcripts authored Feb 7, 2023
1 parent 0dfbddb commit 8e74e9e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h3>Main settings</h3>
<div id="tab_images_content" style="display: none;">
<h3>Large image:</h3>

<input class="dinput" placeholder="Key or URL" id="largeImageKey">
<input class="dinput" placeholder="Key or URL" id="largeImageKey" list="largeImagesList">
<datalist id="largeImagesList"></datalist>
<br>

Expand All @@ -77,7 +77,7 @@ <h3>Large image:</h3>
<br>
<h3>Small image:</h3>

<input class="dinput" placeholder="Key or URL" id="smallImageKey">
<input class="dinput" placeholder="Key or URL" id="smallImageKey" list="smallImagesList">
<datalist id="smallImagesList"></datalist>
<br>

Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const createWindow = () => {
});
mainWindow.setMenu(null)
mainWindow.loadFile(path.join(__dirname, 'index.html'));
mainWindow.webContents.openDevTools();
//mainWindow.webContents.openDevTools();
app.whenReady().then(() => {
dialog.showMessageBox(mainWindow, {title: 'Custom Discord RP', message: 'Started!\n(app will hide in tray)'});
let iconPath = path.join(__dirname, 'icon.png');
Expand Down
25 changes: 20 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ const setStatus = (text, color = 'white') => {
status.style = `color: ${color}; margin-left: 5px;`;
}

const retryConnect = {
state: false,
lastTry: -1
}




document.addEventListener('DOMContentLoaded', async () => {
if (!fs.existsSync(configPath)) save(configPath, {
clientId: '846495641793462292',
Expand All @@ -37,10 +45,16 @@ document.addEventListener('DOMContentLoaded', async () => {
rpc.login({ clientId: config.clientId }).catch((err) => {
setStatus(err, 'red');
if (err.toString() == 'Error: Could not connect') {
setStatus(err + ' (retry in 5 sec.)', 'red');
setInterval(() => location.reload(), 5000)
let sec = 10;
const interval = setInterval(() => {
setStatus(`Retry in ${sec} sec`, 'red')
sec--;
if (sec <= 0) {
clearInterval(interval)
location.reload()
}
}, 1000)
}
//location.reload();
});
rpc.on('ready', () => {
document.getElementById('p_username').textContent = rpc?.user?.username ?? 'Unknown';
Expand Down Expand Up @@ -76,6 +90,7 @@ document.addEventListener('DOMContentLoaded', async () => {
for (const img of applicationImages) {
document.getElementById('largeImagesList').innerHTML += `<option value="${img.name}">`;
document.getElementById('smallImagesList').innerHTML += `<option value="${img.name}">`;
console.log(img.name)
}

// save settings and update presence
Expand Down Expand Up @@ -162,9 +177,9 @@ const startPresence = (config, rpc) => {
rpc.setActivity({
details: config.details.length > 1 ? config.details : undefined,
state: config.state.length > 1 ? config.state : undefined,
largeImageKey: config.largeImageKey,
largeImageKey: config.largeImageKey.length > 1 ? config.largeImageKey : undefined,
largeImageText: config.largeImageText.length > 1 ? config.largeImageText : undefined,
smallImageKey: config.smallImageKey,
smallImageKey: config.smallImageKey.length > 1 ? config.smallImageKey : undefined,
smallImageText: config.smallImageText.length > 1 ? config.smallImageText : undefined,
buttons: getButtons(config.buttons),
startTimestamp: config.enableTimestamp ? Date.now() : undefined,
Expand Down

0 comments on commit 8e74e9e

Please sign in to comment.