| | |
| | | return tag(name) |
| | | } |
| | | |
| | | static func isReservedGroupName(_ name: String, defaultGroupName: String = "Other") -> Bool { |
| | | reservedGroupNames(defaultGroupName: defaultGroupName).contains( |
| | | name.trimmingCharacters(in: .whitespacesAndNewlines) |
| | | ) |
| | | } |
| | | |
| | | private static func isUncategorizedDisplayName(_ name: String) -> Bool { |
| | | name == "Other" || name == tr("group.uncategorized") |
| | | } |
| | | |
| | | private static func isAppleBuiltInDisplayName(_ name: String) -> Bool { |
| | | name == "Mac自带" || name == tr("group.appleBuiltIn") |
| | | } |
| | | |
| | | private static func reservedGroupNames(defaultGroupName: String) -> Set<String> { |
| | | let names = [ |
| | | "Other", |
| | | defaultGroupName, |
| | | tr("group.uncategorized"), |
| | | "Mac自带", |
| | | tr("group.appleBuiltIn"), |
| | | TagDatabase.uncommonTagKey, |
| | | tr("group.uncommon") |
| | | ] |
| | | return Set(names.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.filter { !$0.isEmpty }) |
| | | } |
| | | } |
| | | |
| | |
| | | } else { |
| | | for tag in uniqueOrdered(app.tags) { |
| | | let displayName = nameOverrides[tag] ?? tag |
| | | guard displayName != macCategory else { continue } |
| | | guard !AppContainerID.isReservedGroupName(displayName, defaultGroupName: defaultGroupName) else { |
| | | continue |
| | | } |
| | | appendGroupedApp( |
| | | app, |
| | | to: displayName, |
| | |
| | | tagOrder: tagOrder |
| | | ) { |
| | | let displayName = nameOverrides[tagName] ?? tagName |
| | | guard displayName != macCategory, |
| | | displayName != defaultGroupName |
| | | else { continue } |
| | | guard !AppContainerID.isReservedGroupName(displayName, defaultGroupName: defaultGroupName) else { |
| | | continue |
| | | } |
| | | |
| | | if containerIDsByGroupName[displayName] == nil { |
| | | containerIDsByGroupName[displayName] = AppContainerID.forTag( |