From 289e6d12fc750e6b6581cd91e3b54b6260e57a35 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 21 Jul 2026 15:26:30 -0700 Subject: [PATCH] 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 --- shell/plugins/bar/indicators/Dnd.qml | 4 +--- shell/plugins/notifications/BarWidget.qml | 4 +--- shell/plugins/panels/audio/Panel.qml | 2 +- shell/plugins/services/media/BarWidget.qml | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/shell/plugins/bar/indicators/Dnd.qml b/shell/plugins/bar/indicators/Dnd.qml index 89b0319b..052469bf 100644 --- a/shell/plugins/bar/indicators/Dnd.qml +++ b/shell/plugins/bar/indicators/Dnd.qml @@ -5,9 +5,7 @@ import qs.Ui BarIndicator { id: root - readonly property var notificationService: bar && bar.shell && typeof bar.shell.firstPartyServiceFor === "function" - ? bar.shell.firstPartyServiceFor("omarchy.notifications") - : null + readonly property var notificationService: bar?.shell?.firstPartyServiceFor("omarchy.notifications") readonly property bool dnd: notificationService ? notificationService.doNotDisturb : false active: dnd diff --git a/shell/plugins/notifications/BarWidget.qml b/shell/plugins/notifications/BarWidget.qml index 13c4c538..c517dfa6 100644 --- a/shell/plugins/notifications/BarWidget.qml +++ b/shell/plugins/notifications/BarWidget.qml @@ -25,9 +25,7 @@ BarWidget { // Look up the long-running notifications service through the shell host. readonly property var hostShell: bar && bar.shell ? bar.shell : null - readonly property var notificationService: hostShell && typeof hostShell.firstPartyServiceFor === "function" - ? hostShell.firstPartyServiceFor("omarchy.notifications") - : null + readonly property var notificationService: hostShell?.firstPartyServiceFor("omarchy.notifications") function isChromiumDerived(app, appIcon) { return NotificationLogic.isChromiumDerived(app, appIcon) diff --git a/shell/plugins/panels/audio/Panel.qml b/shell/plugins/panels/audio/Panel.qml index abe73657..5a29b37c 100644 --- a/shell/plugins/panels/audio/Panel.qml +++ b/shell/plugins/panels/audio/Panel.qml @@ -17,7 +17,7 @@ Panel { readonly property var source: Pipewire.defaultAudioSource readonly property var nodes: Pipewire.nodes ? Pipewire.nodes.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 candidateSinks: { diff --git a/shell/plugins/services/media/BarWidget.qml b/shell/plugins/services/media/BarWidget.qml index 942c8b8a..52793c16 100644 --- a/shell/plugins/services/media/BarWidget.qml +++ b/shell/plugins/services/media/BarWidget.qml @@ -7,7 +7,7 @@ BarWidget { id: root 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 sourcePlayers: mediaService ? mediaService.sourcePlayers : []