Skip to content

Commit

Permalink
1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto committed Dec 23, 2024
1 parent a574623 commit 00f1fe9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.3.1

* Fixed some changes on the app

## 1.3.0

* Removed the "Playing" status, now it will always show "Listening to"
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "deezer-discord-rpc",
"version": "1.3.0",
"version": "1.3.1",
"description": "A Discord RPC for Deezer",
"main": "./build/src/index.js",
"scripts": {
"start": "electron ./build/src/index.js",
"build:ts": "tsc --resolveJsonModule",
"build": "yarn build:ts && yarn run copy-assets && node bin/build.js",
"run": "yarn build:ts && yarn run copy-assets && yarn start",
"build": "yarn run build:ts && yarn run copy-assets && node bin/build.js",
"run": "yarn run build:ts && yarn run copy-assets && yarn run start",
"postinstall": "electron-builder install-app-deps",
"lint": "eslint --fix --ext .ts ./src",
"copy-assets": "cpy ./src/img/* ./build/src/img/"
Expand Down
82 changes: 43 additions & 39 deletions src/utils/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ export async function load(app: Electron.App) {
}
});

win.webContents.on('did-stop-loading', () => {
if (win.webContents.navigationHistory.canGoBack()) {
runJs('backButton.style.opacity = \'100%\';');
} else {
runJs('backButton.style.opacity = \'30%\';');
}
if (win.webContents.navigationHistory.canGoForward()) {
runJs('forwardButton.style.opacity = \'100%\';');
} else {
runJs('forwardButton.style.opacity = \'30%\';');
}
});

win.on('close', async (e) => {
if (Config.get(app, 'dont_close_to_tray')) {
await RPC.disconnect();
Expand All @@ -86,46 +99,37 @@ export async function load(app: Electron.App) {
return false;
});

wait(5000).then(() => {
runJs(`document.querySelector('.slider-track-input.mousetrap').addEventListener('click', () => ipcRenderer.send('update_activity', true))
const trackObserver = new MutationObserver(() => ipcRenderer.send('update_activity', false));
trackObserver.observe(document.querySelector('[data-testid="item_title"] a'), { childList: true, subtree: true, characterData: true });
const playingObserver = new MutationObserver(() => ipcRenderer.send('update_activity', false));
playingObserver.observe(document.querySelector('.chakra-button__group > button[data-testid^="play_button_"]'), { childList: true, subtree: true });`);
ipcMain.on('update_activity', (e, currentTimeChanged) => updateActivity(app, currentTimeChanged));
runJs(`const chakraStack = document.querySelector('#dzr-app > .naboo > div > div > a.chakra-link');
const navContainer = document.createElement('div');
navContainer.style.display = 'flex';
navContainer.style.justifyContent = 'space-around';
const backButton = document.createElement('button');
backButton.addEventListener('click', () => ipcRenderer.send('nav_back'));
backButton.textContent = '<';
backButton.style.transform = 'scale(2, 4)';
backButton.style.opacity = '30%';
const forwardButton = document.createElement('button');
forwardButton.addEventListener('click', () => ipcRenderer.send('nav_forward'));
forwardButton.textContent = '>';
forwardButton.style.transform = 'scale(2, 4)';
forwardButton.style.opacity = '30%';
navContainer.appendChild(backButton);
navContainer.appendChild(forwardButton);
chakraStack.replaceWith(navContainer);`);
ipcMain.on('nav_back', () => win.webContents.navigationHistory.goBack());
ipcMain.on('nav_forward', () => win.webContents.navigationHistory.goForward());
win.webContents.on('did-stop-loading', () => {
if (win.webContents.navigationHistory.canGoBack()) {
runJs('backButton.style.opacity = \'100%\';');
} else {
runJs('backButton.style.opacity = \'30%\';');
}
if (win.webContents.navigationHistory.canGoForward()) {
runJs('forwardButton.style.opacity = \'100%\';');
} else {
runJs('forwardButton.style.opacity = \'30%\';');
}
});
setThumbarButtons();
ipcMain.on('update_activity', (_, currentTimeChanged) => {
console.log('update_activity');
updateActivity(app, currentTimeChanged);
});
ipcMain.on('nav_back', () => win.webContents.navigationHistory.goBack());
ipcMain.on('nav_forward', () => win.webContents.navigationHistory.goForward());

await wait(5000);
runJs(`document.querySelector('[data-testid="miniplayer_container"] .slider').addEventListener('click', () => ipcRenderer.send('update_activity', true))
const trackObserver = new MutationObserver(() => ipcRenderer.send('update_activity', false));
trackObserver.observe(document.querySelector('[data-testid="item_title"] a'), { childList: true, subtree: true, characterData: true });
const playingObserver = new MutationObserver(() => ipcRenderer.send('update_activity', false));
playingObserver.observe(document.querySelector('.chakra-button__group > button[data-testid^="play_button_"]'), { childList: true, subtree: true });`);
runJs(`const chakraStack = document.querySelector('#dzr-app > .naboo > div > div > a.chakra-link');
const navContainer = document.createElement('div');
navContainer.style.display = 'flex';
navContainer.style.justifyContent = 'space-around';
const backButton = document.createElement('button');
backButton.addEventListener('click', () => ipcRenderer.send('nav_back'));
backButton.textContent = '<';
backButton.style.transform = 'scale(2, 4)';
backButton.style.opacity = '30%';
const forwardButton = document.createElement('button');
forwardButton.addEventListener('click', () => ipcRenderer.send('nav_forward'));
forwardButton.textContent = '>';
forwardButton.style.transform = 'scale(2, 4)';
forwardButton.style.opacity = '30%';
navContainer.appendChild(backButton);
navContainer.appendChild(forwardButton);
chakraStack.replaceWith(navContainer);`);
setThumbarButtons();
}

export async function showWindow() {
Expand Down

0 comments on commit 00f1fe9

Please sign in to comment.