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,7 +35,9 @@ 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))
return;
player.colors.value = JSON.parse(out); player.colors.value = JSON.parse(out);
box._bgStyle = `background: radial-gradient(circle, box._bgStyle = `background: radial-gradient(circle,
@ -45,7 +48,6 @@ export const CoverArt = (player, params) => CenterBox({
background-position: center;`; background-position: center;`;
if (!box.get_parent()._dragging) if (!box.get_parent()._dragging)
box.setStyle(box._bgStyle); 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) {