From 0c3e3c9f9c011326ac6cda3b9b1c37148a543fa8 Mon Sep 17 00:00:00 2001 From: Emerald Lockdown Date: Fri, 5 May 2023 12:17:59 -0500 Subject: [PATCH 1/4] Fix another performance issue, and add alert to removing repo with removing repo files as well --- sm_osx.xcodeproj/project.pbxproj | 10 ++-- sm_osx/GeneralView.swift | 41 +++++++------- sm_osx/LauncherGridView.swift | 96 ++++++++++++++++++++++++-------- sm_osx/LauncherListView.swift | 7 ++- sm_osx/LauncherView.swift | 7 ++- sm_osx/MenuCommands.swift | 14 ++++- 6 files changed, 125 insertions(+), 50 deletions(-) diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index 2fd2833..dabc997 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -415,7 +415,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -431,10 +431,11 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.5; + MARKETING_VERSION = 1.3.0.8; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; }; @@ -449,7 +450,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -465,10 +466,11 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.5; + MARKETING_VERSION = 1.3.0.8; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; }; diff --git a/sm_osx/GeneralView.swift b/sm_osx/GeneralView.swift index 9144cee..cc7b308 100644 --- a/sm_osx/GeneralView.swift +++ b/sm_osx/GeneralView.swift @@ -16,29 +16,30 @@ struct GeneralView: View { let outHandle = pipe.fileHandleForReading outHandle.readabilityHandler = { pipe in - if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) { - if line.contains("Finished installing deps") { - - withAnimation() { - isInstallingDeps = false + if pipe.availableData.count > 0 { + if let line = String(data: pipe.availableData, encoding: String.Encoding.utf8) { + if line.contains("Finished installing deps") { + + withAnimation() { + isInstallingDeps = false + } + + let content = UNMutableNotificationContent() + content.title = "Finished installing dependencies" + content.subtitle = "Dependencies are now installed." + content.sound = UNNotificationSound.default + + let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false) + + let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) + + UNUserNotificationCenter.current().add(request) } - - let content = UNMutableNotificationContent() - content.title = "Finished installing dependencies" - content.subtitle = "Dependencies are now installed." - content.sound = UNNotificationSound.default - - // show this notification instantly - let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.0001, repeats: false) - - // choose a random identifier - let request = UNNotificationRequest(identifier: UUID().uuidString, content: content, trigger: trigger) - - // add our notification request - UNUserNotificationCenter.current().add(request) + } else { + print("Error decoding data. why do I program...: \(pipe.availableData)") } } else { - print("Error decoding data. why do I program...: \(pipe.availableData)") + outHandle.readabilityHandler = nil } } diff --git a/sm_osx/LauncherGridView.swift b/sm_osx/LauncherGridView.swift index 998801f..cc22166 100644 --- a/sm_osx/LauncherGridView.swift +++ b/sm_osx/LauncherGridView.swift @@ -9,6 +9,9 @@ struct LauncherGridView: View { @FetchRequest(sortDescriptors:[SortDescriptor(\.title)]) var launcherRepos: FetchedResults @Binding var reloadMenuBarLauncher: Bool @Binding var existingRepo: URL? + @State var removeEntireRepo = false + @State var removeRepo = false + @State var item: Int? = nil let layout = [GridItem(.adaptive(minimum: 260))] func launcherShell(_ command: String) { @@ -34,8 +37,13 @@ struct LauncherGridView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } @@ -49,6 +57,7 @@ struct LauncherGridView: View { LazyVGrid(columns: layout) { ForEach(launcherRepos) { LauncherRepo in let i = launcherRepos.firstIndex(of: LauncherRepo) ?? 0 + VStack { Button { @@ -102,26 +111,8 @@ struct LauncherGridView: View { } Button(action: { - - if launcherRepos.isEmpty { return } - - for i in 0...launcherRepos.count - 1 { - launcherRepos[i].isEditing = false - } - - let launcherRepo = launcherRepos[i] - - moc.delete(launcherRepo) - - do { - try withAnimation { - try moc.save() - } - reloadMenuBarLauncher = true - } - catch { - print("Error: its broken: \(error)") - } + item = i + removeRepo = true }) { Text("Remove Repo") } @@ -146,6 +137,67 @@ struct LauncherGridView: View { LauncherEditView(i: i, existingRepo: $existingRepo, reloadMenuBarLauncher: $reloadMenuBarLauncher) } } - }.padding(15) + }.alert("Are You Sure You Want to Remove the Repo?", isPresented: $removeEntireRepo) { + Button("Yes", role: .destructive) { + + if launcherRepos.isEmpty { return } + + let launcherRepo = launcherRepos[item!] + + do { + let path = URL(filePath: (launcherRepo.path!)).deletingLastPathComponent().path() + + Shell().shell("rm -rf \(path)") + } catch { + print("Error, could not delete file due to: \(error)") + } + + moc.delete(launcherRepo) + + do { + try withAnimation { + try moc.save() + } + reloadMenuBarLauncher = true + } catch { + print("Error: its broken: \(error)") + } + + item = nil + } + + Button("No", role: .cancel) {} + } message: { + Text("Make sure there are no important files in that folder!") + } + .padding(15) + .alert("Remove Repo \(launcherRepos[item ?? 0].title ?? "")?", isPresented: $removeRepo) { + Button("Remove Repo", role: .destructive) { + removeEntireRepo = true + } + + Button("Remove Entry", role: .destructive) { + if item != nil { + if launcherRepos.isEmpty { return } + + let launcherRepo = launcherRepos[item!] + + moc.delete(launcherRepo) + + do { + try withAnimation { + try moc.save() + } + reloadMenuBarLauncher = true + } catch { + print("Error: its broken: \(error)") + } + + item = nil + } + } + + Button("Cancel", role: .cancel) {} + } } } diff --git a/sm_osx/LauncherListView.swift b/sm_osx/LauncherListView.swift index 613aad6..e804d0f 100644 --- a/sm_osx/LauncherListView.swift +++ b/sm_osx/LauncherListView.swift @@ -33,8 +33,13 @@ struct LauncherListView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } diff --git a/sm_osx/LauncherView.swift b/sm_osx/LauncherView.swift index f21eeca..4c3f71c 100644 --- a/sm_osx/LauncherView.swift +++ b/sm_osx/LauncherView.swift @@ -49,8 +49,13 @@ struct LauncherView: View { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } diff --git a/sm_osx/MenuCommands.swift b/sm_osx/MenuCommands.swift index e603210..89d5d91 100644 --- a/sm_osx/MenuCommands.swift +++ b/sm_osx/MenuCommands.swift @@ -52,8 +52,13 @@ struct MenuCommands: Commands { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } @@ -186,8 +191,13 @@ struct menuExtras: Scene { } var observer : NSObjectProtocol? - observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { notification -> Void in + observer = NotificationCenter.default.addObserver(forName: Process.didTerminateNotification, object: process, queue: nil) { [observer] _ in if process.terminationStatus != 0 { + + if NSApp.activationPolicy() == .prohibited { + showApp() + } + openWindow(id: "crash-log", value: output) } From 2734aa86e74ebb8f05d82f8382642433c3b8140f Mon Sep 17 00:00:00 2001 From: Emerald Lockdown Date: Fri, 5 May 2023 12:19:10 -0500 Subject: [PATCH 2/4] v1.3.0.9 --- sm_osx.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index dabc997..9e945b8 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -415,7 +415,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -431,7 +431,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.8; + MARKETING_VERSION = 1.3.0.9; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -450,7 +450,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 8; + CURRENT_PROJECT_VERSION = 9; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -466,7 +466,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.8; + MARKETING_VERSION = 1.3.0.9; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; From dcf188b6543d1ae48046b41cf1fd7f1b97d5c064 Mon Sep 17 00:00:00 2001 From: Emerald Lockdown Date: Fri, 19 May 2023 16:01:49 -0500 Subject: [PATCH 3/4] Fix intel homebrew bug and use file manager instead of shell --- sm_osx.xcodeproj/project.pbxproj | 8 ++++---- sm_osx/FirstLaunchView.swift | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index 9e945b8..63a23f1 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -415,7 +415,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -431,7 +431,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.9; + MARKETING_VERSION = 1.3.0.91; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -450,7 +450,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 9; + CURRENT_PROJECT_VERSION = 10; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"sm_osx/Preview Content\""; DEVELOPMENT_TEAM = 25RK3JMVLT; @@ -466,7 +466,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.9; + MARKETING_VERSION = 1.3.0.91; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/sm_osx/FirstLaunchView.swift b/sm_osx/FirstLaunchView.swift index d52b98f..bcc7a8c 100644 --- a/sm_osx/FirstLaunchView.swift +++ b/sm_osx/FirstLaunchView.swift @@ -148,7 +148,7 @@ struct FirstLaunchView: View { Text("Checking Homebrew Installation...") .onAppear { if isArm() { - if !((Shell().shell("which brew"))).contains("/opt/homebrew/bin/brew") { + if !FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -161,7 +161,7 @@ struct FirstLaunchView: View { } } } else { - if Shell().shell("which brew").contains("/usr/local/bin/brew") { + if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -176,13 +176,13 @@ struct FirstLaunchView: View { } }.onReceive(timer) { _ in if isArm() { - if Shell().shell("which brew").contains("/opt/homebrew/bin/brew") { + if FileManager.default.fileExists(atPath: "/opt/homebrew/bin/brew") { withAnimation { status = .checkingIntelHomebrewInstallation } } } else { - if Shell().shell("which brew").contains("/usr/local/bin/brew") { + if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { withAnimation { status = .installingDeps } @@ -192,7 +192,7 @@ struct FirstLaunchView: View { } else if status == .checkingIntelHomebrewInstallation { Text("Checking Intel Homebrew Installation...") .onAppear { - if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") { + if !FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { let task = Process() task.launchPath = "/usr/bin/osascript" @@ -205,7 +205,7 @@ struct FirstLaunchView: View { } } }.onReceive(timer) { _ in - if Shell().shell("which /usr/local/bin/brew").contains("/usr/local/bin/brew\n") { + if FileManager.default.fileExists(atPath: "/usr/local/bin/brew") { withAnimation(.linear(duration: 0.4)) { status = .installingDeps } From 603791f65cdfba945707dc82a1aaec6ad1d52ef9 Mon Sep 17 00:00:00 2001 From: Emerald Lockdown Date: Fri, 19 May 2023 16:10:01 -0500 Subject: [PATCH 4/4] Fix issue with homebrew installing intel version on arm when its meant to install arm version --- sm_osx.xcodeproj/project.pbxproj | 4 ++-- sm_osx/HomebrewInstaller.scpt | Bin 1776 -> 1578 bytes 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sm_osx.xcodeproj/project.pbxproj b/sm_osx.xcodeproj/project.pbxproj index 63a23f1..110dcf0 100644 --- a/sm_osx.xcodeproj/project.pbxproj +++ b/sm_osx.xcodeproj/project.pbxproj @@ -431,7 +431,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.91; + MARKETING_VERSION = 1.3.0.92; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -466,7 +466,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.3.0.91; + MARKETING_VERSION = 1.3.0.92; ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.CubingStudios.sm-osx"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/sm_osx/HomebrewInstaller.scpt b/sm_osx/HomebrewInstaller.scpt index 866dddd78696aed563600be1d517925ab1369476..bd7f7582f8082407f1f751595069d040d7dda6a8 100644 GIT binary patch delta 420 zcmXX?%PvDv6kX@u>#7q+TiRZAU2oE~!olnt7>_Zab7O6N=`qX;dOu*(lJibZe9J#l%yRYEE zS}+3>nBgl1r2$87pX?qg40cvcVVW(QEeMxyfW;3$!R-_QfpipUaT(F~_L_dOyLHT& zw^tvsddXS+^XE=I(ZmpZ!6pzhkzhlzq3^nUuMa-DW2|GCHC7Q|gfEhHQwvsxJG4U? zMlFmQx`Gvp6?2re@RMq|E(l=+5u{mWiA5HWWS-BG<$o%YC7p2tQPgqa+mZ#nDSRcF k{}(~>*=XnY#QB2RQa>{K#+`|7M6q?eePjr#uR`Ja7v`UQCjbBd delta 629 zcmZ{hOHWfl6vzK_Zy#~O6w0G5Ew{AxK~e-H0zSTh3qxGEGSM`R2GW9rhq}Y1CN4FVvh|%^-_d1Tm;}#G{BK zjWQNd!HgV@;3aNJ@5izxBwxZz2z{{m0|}mL2?1SwI$JYHz?zV5S5f45^lNbeU3oD( zZ_w}0$)ms%n4r7vSq%fe__6XxCzj7GY;6&hfgy|^K?icmx z;ebGV!ysE)!X?C@4>5vqenm!$yM)O2t;TSjM>dZ|5q5~{lD}6a>&AvsH3=RaaXuF-t=hqyy*qc6>$Yw?r@u1tRu!vZotvp zxp=VVwmTPe)Rr4nDO