Simplify service lookups with optional chaining
The bar-null-shell-null-typeof-function ternary guarded against our own shell missing a method it always defines. bar?.shell?.firstPartyServiceFor() handles the only real case, delayed bar injection, in one line. The typeof checks that probe genuinely third-party plugin objects stay. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
ba91bad3a4
commit
289e6d12fc
@@ -5,9 +5,7 @@ import qs.Ui
|
|||||||
BarIndicator {
|
BarIndicator {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property var notificationService: bar && bar.shell && typeof bar.shell.firstPartyServiceFor === "function"
|
readonly property var notificationService: bar?.shell?.firstPartyServiceFor("omarchy.notifications")
|
||||||
? bar.shell.firstPartyServiceFor("omarchy.notifications")
|
|
||||||
: null
|
|
||||||
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false
|
||||||
|
|
||||||
active: dnd
|
active: dnd
|
||||||
|
|||||||
@@ -25,9 +25,7 @@ BarWidget {
|
|||||||
|
|
||||||
// Look up the long-running notifications service through the shell host.
|
// Look up the long-running notifications service through the shell host.
|
||||||
readonly property var hostShell: bar && bar.shell ? bar.shell : null
|
readonly property var hostShell: bar && bar.shell ? bar.shell : null
|
||||||
readonly property var notificationService: hostShell && typeof hostShell.firstPartyServiceFor === "function"
|
readonly property var notificationService: hostShell?.firstPartyServiceFor("omarchy.notifications")
|
||||||
? hostShell.firstPartyServiceFor("omarchy.notifications")
|
|
||||||
: null
|
|
||||||
|
|
||||||
function isChromiumDerived(app, appIcon) {
|
function isChromiumDerived(app, appIcon) {
|
||||||
return NotificationLogic.isChromiumDerived(app, appIcon)
|
return NotificationLogic.isChromiumDerived(app, appIcon)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Panel {
|
|||||||
readonly property var source: Pipewire.defaultAudioSource
|
readonly property var source: Pipewire.defaultAudioSource
|
||||||
readonly property var nodes: Pipewire.nodes ? Pipewire.nodes.values : []
|
readonly property var nodes: Pipewire.nodes ? Pipewire.nodes.values : []
|
||||||
readonly property var mprisPlayers: Mpris.players ? Mpris.players.values : []
|
readonly property var mprisPlayers: Mpris.players ? Mpris.players.values : []
|
||||||
readonly property var mediaService: bar && bar.shell ? bar.shell.firstPartyServiceFor("omarchy.media") : null
|
readonly property var mediaService: bar?.shell?.firstPartyServiceFor("omarchy.media")
|
||||||
readonly property var activeMediaPlayer: mediaService ? mediaService.activePlayer : null
|
readonly property var activeMediaPlayer: mediaService ? mediaService.activePlayer : null
|
||||||
|
|
||||||
readonly property var candidateSinks: {
|
readonly property var candidateSinks: {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ BarWidget {
|
|||||||
id: root
|
id: root
|
||||||
moduleName: "omarchy.media"
|
moduleName: "omarchy.media"
|
||||||
|
|
||||||
readonly property var mediaService: bar && bar.shell ? bar.shell.firstPartyServiceFor("omarchy.media") : null
|
readonly property var mediaService: bar?.shell?.firstPartyServiceFor("omarchy.media")
|
||||||
readonly property var activePlayer: mediaService ? mediaService.activePlayer : null
|
readonly property var activePlayer: mediaService ? mediaService.activePlayer : null
|
||||||
readonly property var sourcePlayers: mediaService ? mediaService.sourcePlayers : []
|
readonly property var sourcePlayers: mediaService ? mediaService.sourcePlayers : []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user