diff --git a/src/components/menus/media/components/controls/Players.tsx b/src/components/menus/media/components/controls/Players.tsx index 81baf17..c2c8770 100644 --- a/src/components/menus/media/components/controls/Players.tsx +++ b/src/components/menus/media/components/controls/Players.tsx @@ -5,8 +5,8 @@ import { isPrimaryClick } from 'src/lib/utils'; import { getNextPlayer, getPreviousPlayer } from './helpers'; export const PreviousPlayer = (): JSX.Element => { - const className = bind(mprisService, 'players').as(() => { - const isDisabled = mprisService.players.length <= 1 ? 'disabled' : 'enabled'; + const className = bind(mprisService, 'players').as((players) => { + const isDisabled = players.length <= 1 ? 'disabled' : 'enabled'; return `media-indicator-control-button ${isDisabled}`; }); @@ -16,7 +16,7 @@ export const PreviousPlayer = (): JSX.Element => { return; } - const isDisabled = mprisService.players.length <= 1; + const isDisabled = mprisService.get_players().length <= 1; if (!isDisabled) { getPreviousPlayer(); @@ -37,8 +37,8 @@ export const PreviousPlayer = (): JSX.Element => { }; export const NextPlayer = (): JSX.Element => { - const className = bind(mprisService, 'players').as(() => { - const isDisabled = mprisService.players.length <= 1 ? 'disabled' : 'enabled'; + const className = bind(mprisService, 'players').as((players) => { + const isDisabled = players.length <= 1 ? 'disabled' : 'enabled'; return `media-indicator-control-button ${isDisabled}`; }); const onClick = (_: Widget.Button, event: Astal.ClickEvent): void => { @@ -46,7 +46,7 @@ export const NextPlayer = (): JSX.Element => { return; } - const isDisabled = mprisService.players.length <= 1; + const isDisabled = mprisService.get_players().length <= 1; if (!isDisabled) { getNextPlayer(); diff --git a/src/components/menus/media/components/controls/helpers.ts b/src/components/menus/media/components/controls/helpers.ts index 9ab9372..420d3df 100644 --- a/src/components/menus/media/components/controls/helpers.ts +++ b/src/components/menus/media/components/controls/helpers.ts @@ -86,14 +86,16 @@ export const getNextPlayer = (): void => { return; } - const currentPlayerIndex = mprisService.players.findIndex((player) => player.busName === currentPlayer.busName); - const totalPlayers = mprisService.players.length; + const currentPlayerIndex = mprisService + .get_players() + .findIndex((player) => player.busName === currentPlayer.busName); + const totalPlayers = mprisService.get_players().length; if (totalPlayers === 1) { - return activePlayer.set(mprisService.players[0]); + return activePlayer.set(mprisService.get_players()[0]); } - return activePlayer.set(mprisService.players[(currentPlayerIndex + 1) % totalPlayers]); + return activePlayer.set(mprisService.get_players()[(currentPlayerIndex + 1) % totalPlayers]); }; /** @@ -111,12 +113,14 @@ export const getPreviousPlayer = (): void => { return; } - const currentPlayerIndex = mprisService.players.findIndex((player) => player.busName === currentPlayer.busName); - const totalPlayers = mprisService.players.length; + const currentPlayerIndex = mprisService + .get_players() + .findIndex((player) => player.busName === currentPlayer.busName); + const totalPlayers = mprisService.get_players().length; if (totalPlayers === 1) { - return activePlayer.set(mprisService.players[0]); + return activePlayer.set(mprisService.get_players()[0]); } - return activePlayer.set(mprisService.players[(currentPlayerIndex - 1 + totalPlayers) % totalPlayers]); + return activePlayer.set(mprisService.get_players()[(currentPlayerIndex - 1 + totalPlayers) % totalPlayers]); }; diff --git a/src/components/menus/media/components/helpers.ts b/src/components/menus/media/components/helpers.ts index 667defa..45eaea3 100644 --- a/src/components/menus/media/components/helpers.ts +++ b/src/components/menus/media/components/helpers.ts @@ -52,13 +52,15 @@ export const initializeActivePlayerHook = (): void => { [AstalMpris.PlaybackStatus.STOPPED]: 3, }; - const isPlaying = mprisService.players.find((p) => p['playbackStatus'] === AstalMpris.PlaybackStatus.PLAYING); + const isPlaying = mprisService + .get_players() + .find((p) => p['playbackStatus'] === AstalMpris.PlaybackStatus.PLAYING); - const playerStillExists = mprisService.players.some((player) => curPlayer.set(player.busName)); + const playerStillExists = mprisService.get_players().some((player) => curPlayer.set(player.busName)); - const nextPlayerUp = mprisService.players.sort( - (a, b) => statusOrder[a.playbackStatus] - statusOrder[b.playbackStatus], - )[0].bus_name; + const nextPlayerUp = mprisService + .get_players() + .sort((a, b) => statusOrder[a.playbackStatus] - statusOrder[b.playbackStatus])[0].bus_name; if (isPlaying || !playerStillExists) { curPlayer.set(nextPlayerUp); diff --git a/src/components/menus/notifications/controls/ClearNotificationsButton.tsx b/src/components/menus/notifications/controls/ClearNotificationsButton.tsx index 5cab14d..196436e 100644 --- a/src/components/menus/notifications/controls/ClearNotificationsButton.tsx +++ b/src/components/menus/notifications/controls/ClearNotificationsButton.tsx @@ -20,7 +20,7 @@ export const ClearNotificationsButton = (): JSX.Element => { return; } - clearNotifications(notifdService.notifications, clearDelay.get()); + clearNotifications(notifdService.get_notifications(), clearDelay.get()); }} >