Skip to content

Commit

Permalink
common refactor
Browse files Browse the repository at this point in the history
Signed-off-by: 82Flex <[email protected]>
  • Loading branch information
Lessica committed Jul 22, 2024
1 parent 73255ff commit 4eca358
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions TrollFools/AppListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class App: Identifiable, ObservableObject {
lazy var isSystem: Bool = !isUser
lazy var isFromApple: Bool = id.hasPrefix("com.apple.")
lazy var isFromTroll: Bool = isSystem && !isFromApple
lazy var isRemovableSystem: Bool = isSystem && url.path.contains("/var/containers/Bundle/Application/")
lazy var isRemovable: Bool = url.path.contains("/var/containers/Bundle/Application/")

init(id: String,
name: String,
Expand Down Expand Up @@ -64,6 +64,11 @@ final class AppListModel: ObservableObject {
self.allApplications = Self.fetchApplications(&hasTrollRecorder, &unsupportedCount)
}

private static let excludedIdentifiers: Set<String> = [
"com.opa334.Dopamine",
"org.coolstar.SileoStore",
]

private static func fetchApplications(_ hasTrollRecorder: inout Bool, _ unsupportedCount: inout Int) -> [App] {
let allApps: [App] = LSApplicationWorkspace.default()
.allApplications()
Expand All @@ -77,9 +82,19 @@ final class AppListModel: ObservableObject {
else {
return nil
}

if id == "wiki.qaq.trapp" {
hasTrollRecorder = true
}

guard !id.hasPrefix("wiki.qaq.") && !id.hasPrefix("com.82flex.") else {
return nil
}

guard !excludedIdentifiers.contains(id) else {
return nil
}

let app = App(
id: id,
name: localizedName,
Expand All @@ -88,9 +103,15 @@ final class AppListModel: ObservableObject {
url: url,
version: shortVersionString
)
guard !app.isFromApple || app.isRemovableSystem else {

if app.isUser && app.isFromApple {
return nil
}

guard app.isRemovable else {
return nil
}

return app
}

Expand Down

0 comments on commit 4eca358

Please sign in to comment.