fix(ags media-player): wrap in Box to have correct margin

This commit is contained in:
matt1432 2023-09-26 10:47:36 -04:00
parent 28881bd2dd
commit 812c1b7a52

View file

@ -83,55 +83,57 @@ const PlayerBox = player => mpris.CoverArt(player, {
], ],
}); });
export default () => PlayerGesture({ export default () => Box({
className: 'media', className: 'media',
properties: [ child: PlayerGesture({
['players', new Map()], properties: [
['setup', false], ['players', new Map()],
['selected'], ['setup', false],
], ['selected'],
connections: [ ],
[Mpris, (overlay, busName) => { connections: [
if (!busName || overlay._players.has(busName)) [Mpris, (overlay, busName) => {
return; if (!busName || overlay._players.has(busName))
return;
const player = Mpris.getPlayer(busName); const player = Mpris.getPlayer(busName);
player.colors = ags.Variable(); player.colors = ags.Variable();
overlay._players.set(busName, PlayerBox(player)); overlay._players.set(busName, PlayerBox(player));
let result = []; let result = [];
overlay._players.forEach(widget => { overlay._players.forEach(widget => {
result.push(widget); result.push(widget);
}); });
overlay.overlays = result; overlay.overlays = result;
// Favor spotify // Favor spotify
if (!overlay._setup) { if (!overlay._setup) {
if (overlay._players.has('org.mpris.MediaPlayer2.spotify')) { if (overlay._players.has('org.mpris.MediaPlayer2.spotify')) {
overlay._selected = overlay._players.get('org.mpris.MediaPlayer2.spotify'); overlay._selected = overlay._players.get('org.mpris.MediaPlayer2.spotify');
}
overlay._setup = true;
} }
overlay._setup = true;
}
if (overlay._selected) if (overlay._selected)
overlay.reorder_overlay(overlay._selected, -1); overlay.reorder_overlay(overlay._selected, -1);
}, 'player-added'], }, 'player-added'],
[Mpris, (overlay, busName) => { [Mpris, (overlay, busName) => {
if (!busName || !overlay._players.has(busName)) if (!busName || !overlay._players.has(busName))
return; return;
overlay._players.delete(busName); overlay._players.delete(busName);
let result = []; let result = [];
overlay._players.forEach(widget => { overlay._players.forEach(widget => {
result.push(widget); result.push(widget);
}); });
overlay.overlays = result; overlay.overlays = result;
if (overlay._selected) if (overlay._selected)
overlay.reorder_overlay(overlay._selected, -1); overlay.reorder_overlay(overlay._selected, -1);
}, 'player-closed'], }, 'player-closed'],
], ],
}) }),
});