fix(ags player): get rid of already disposed errors

This commit is contained in:
matt1432 2023-09-26 14:17:13 -04:00
parent b9807c29cf
commit 61fadfce61

View file

@ -1,4 +1,5 @@
const { execAsync, lookUpIcon } = ags.Utils; const { execAsync, lookUpIcon } = ags.Utils;
const { Mpris } = ags.Service;
const { Button, Icon, Label, Stack, Slider, CenterBox } = ags.Widget; const { Button, Icon, Label, Stack, Slider, CenterBox } = ags.Widget;
const { Gdk } = imports.gi; const { Gdk } = imports.gi;
const display = Gdk.Display.get_default(); const display = Gdk.Display.get_default();
@ -34,18 +35,19 @@ export const CoverArt = (player, params) => CenterBox({
[player, box => { [player, box => {
execAsync(['bash', '-c', `[[ -f "${player.coverPath}" ]] && coloryou "${player.coverPath}"`]) execAsync(['bash', '-c', `[[ -f "${player.coverPath}" ]] && coloryou "${player.coverPath}"`])
.then(out => { .then(out => {
if (box) { if (!Mpris.players.find(p => player === p))
player.colors.value = JSON.parse(out); return;
box._bgStyle = `background: radial-gradient(circle, player.colors.value = JSON.parse(out);
rgba(0, 0, 0, 0.4) 30%,
${player.colors.value.imageAccent}), box._bgStyle = `background: radial-gradient(circle,
url("${player.coverPath}"); rgba(0, 0, 0, 0.4) 30%,
background-size: cover; ${player.colors.value.imageAccent}),
background-position: center;`; url("${player.coverPath}");
if (!box.get_parent()._dragging) background-size: cover;
box.setStyle(box._bgStyle); background-position: center;`;
} if (!box.get_parent()._dragging)
box.setStyle(box._bgStyle);
}).catch(err => { if (err !== "") print(err) }); }).catch(err => { if (err !== "") print(err) });
}], }],
], ],
@ -197,6 +199,9 @@ const PlayerButton = ({ player, items, onClick, prop }) => Button({
}], }],
[player.colors, button => { [player.colors, button => {
if (!Mpris.players.find(p => player === p))
return;
if (player.colors.value) { if (player.colors.value) {
if (prop == 'playBackStatus') { if (prop == 'playBackStatus') {
if (button._hovered) { if (button._hovered) {