Skip to content

Commit

Permalink
馃悰 Various bugfixes
Browse files Browse the repository at this point in the history
- Fixes issue with `scanApps` being non-optional in custom configuration
- Fixes issue with position of separator if Xdebug is not detected
- Ensure that `isRunningSwiftUIPreview` modifier always return false for debug builds
  • Loading branch information
nicoverbruggen committed Sep 23, 2022
1 parent ddfc73e commit bdb7185
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions phpmon/Domain/Menu/MainMenu+Startup.swift
Expand Up @@ -155,11 +155,11 @@ extension MainMenu {

App.shared.detectedApplications = Application.detectPresetApplications()

let customApps = Preferences.custom.scanApps.map { appName in
let customApps = Preferences.custom.scanApps?.map { appName in
return Application(appName, .user_supplied)
}.filter { app in
return app.isInstalled()
}
} ?? []

App.shared.detectedApplications.append(contentsOf: customApps)

Expand Down
4 changes: 2 additions & 2 deletions phpmon/Domain/Menu/StatusMenu+Items.swift
Expand Up @@ -216,14 +216,14 @@ extension StatusMenu {
}

addItems([
NSMenuItem.separator(),
NSMenuItem(title: "mi_xdebug_mode".localized, submenu: [
HeaderView.asMenuItem(text: "mi_xdebug_available_modes".localized)
] + Xdebug.asMenuItems() + [
HeaderView.asMenuItem(text: "mi_xdebug_actions".localized),
NSMenuItem(title: "mi_xdebug_disable_all".localized,
action: #selector(MainMenu.disableAllXdebugModes))
], target: MainMenu.shared)
], target: MainMenu.shared),
NSMenuItem.separator()
], target: MainMenu.shared)
}

Expand Down
3 changes: 2 additions & 1 deletion phpmon/Domain/Menu/StatusMenu.swift
Expand Up @@ -48,8 +48,9 @@ class StatusMenu: NSMenu {

if Preferences.isEnabled(.displayExtensions) {
addExtensionsMenuItems()
addXdebugMenuItem()
NSMenuItem.separator()

addXdebugMenuItem()
}

addPhpDoctorMenuItem()
Expand Down
2 changes: 1 addition & 1 deletion phpmon/Domain/Preferences/CustomPrefs.swift
Expand Up @@ -9,7 +9,7 @@
import Foundation

struct CustomPrefs: Decodable {
let scanApps: [String]
let scanApps: [String]?
let presets: [Preset]?
let services: [String]?
let environmentVariables: [String: String]?
Expand Down
9 changes: 7 additions & 2 deletions phpmon/Domain/SwiftUI/Common/SwiftUIHelper.swift
Expand Up @@ -10,8 +10,13 @@ import Foundation
import SwiftUI

var isRunningSwiftUIPreview: Bool {
return ProcessInfo.processInfo
.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
#if DEBUG
// If running SwiftUI *and* when debugging
return ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
#else
// Release builds should always return false here
return false
#endif
}

extension Color {
Expand Down

0 comments on commit bdb7185

Please sign in to comment.