From 20821274a97905fad125644c3daeef5a5a552296 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:38:33 +0000 Subject: [PATCH 1/4] Initial plan From a1e9a6c9747cc46818bcadf727352fd668ddf844 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 13:41:29 +0000 Subject: [PATCH 2/4] Set userEnabledRPC to true by default to enable Rich Presence toggle on by default Co-authored-by: thehairy <71461991+thehairy@users.noreply.github.com> --- iRPC/ContentView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iRPC/ContentView.swift b/iRPC/ContentView.swift index 624646d..d6827f9 100644 --- a/iRPC/ContentView.swift +++ b/iRPC/ContentView.swift @@ -20,7 +20,7 @@ struct ContentView: View { @State private var isAuthorized = false @State private var isLoading = true @State private var isAuthenticating = false - @State private var userEnabledRPC = false + @State private var userEnabledRPC = true @State private var showRPCToggle = false @StateObject private var discord = DiscordManager(applicationId: 1_370_062_110_272_520_313) private let manager = NowPlayingManager.shared From 7c74604bec4cb4fdc6cb533ae10eef0c8b1ae6a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:41:18 +0000 Subject: [PATCH 3/4] Auto-start RPC when Discord becomes ready if userEnabledRPC is enabled by default Co-authored-by: thehairy <71461991+thehairy@users.noreply.github.com> --- iRPC/ContentView.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/iRPC/ContentView.swift b/iRPC/ContentView.swift index d6827f9..4a37b7c 100644 --- a/iRPC/ContentView.swift +++ b/iRPC/ContentView.swift @@ -308,6 +308,9 @@ struct ContentView: View { print("🔄 Discord state changed: Auth=\(authenticated) Ready=\(ready) User=\(username ?? "none")") + // Check if Discord just became ready while userEnabledRPC is on (default) + let justBecameReady = !isDiscordReady && ready && authenticated + // Update our tracked state isDiscordAuthenticated = authenticated isDiscordReady = ready @@ -315,6 +318,16 @@ struct ContentView: View { // Force UI refresh forceConnectionRefresh = UUID() + + // Auto-start RPC if Discord just became ready and userEnabledRPC is enabled (default) + if justBecameReady && userEnabledRPC { + print("🚀 Discord ready with RPC enabled by default - starting presence updates") + discord.startPresenceUpdates() + BackgroundController.shared.start() + if manager.isPlaying { + Task { await updateDiscordWithCurrentSong() } + } + } } } From b363bb0686cdc922e13b31f1f2516a69cdf4431a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 2 Dec 2025 18:43:03 +0000 Subject: [PATCH 4/4] Refactor: extract startRPCServices() and stopRPCServices() to reduce code duplication Co-authored-by: thehairy <71461991+thehairy@users.noreply.github.com> --- iRPC/ContentView.swift | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/iRPC/ContentView.swift b/iRPC/ContentView.swift index 4a37b7c..c2891a3 100644 --- a/iRPC/ContentView.swift +++ b/iRPC/ContentView.swift @@ -322,11 +322,7 @@ struct ContentView: View { // Auto-start RPC if Discord just became ready and userEnabledRPC is enabled (default) if justBecameReady && userEnabledRPC { print("🚀 Discord ready with RPC enabled by default - starting presence updates") - discord.startPresenceUpdates() - BackgroundController.shared.start() - if manager.isPlaying { - Task { await updateDiscordWithCurrentSong() } - } + startRPCServices() } } } @@ -536,18 +532,26 @@ struct ContentView: View { } } + private func startRPCServices() { + discord.startPresenceUpdates() + BackgroundController.shared.start() + if manager.isPlaying { + Task { await updateDiscordWithCurrentSong() } + } + } + + private func stopRPCServices() { + discord.stopPresenceUpdates() + BackgroundController.shared.stop() + } + private func handleUserToggleRPC(enabled: Bool) { print("🎮 User toggled Discord RPC: \(enabled ? "ON" : "OFF")") if enabled { - discord.startPresenceUpdates() - if manager.isPlaying { - Task { await updateDiscordWithCurrentSong() } - } - BackgroundController.shared.start() + startRPCServices() } else { - discord.stopPresenceUpdates() - BackgroundController.shared.stop() + stopRPCServices() } }