Skip to content

Commit d4048ad

Browse files
Drop emoji support in CartographyIcon
This appears to be causing too many issues for clients to properly decode, so the icons are now limited to just semantic tokens.
1 parent e280f6e commit d4048ad

File tree

2 files changed

+1
-57
lines changed

2 files changed

+1
-57
lines changed

Sources/MCMap/Library/CartographyIcon.swift

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// An enumeration of custom icons that can be used in a `.mcmap` package.
11-
public enum CartographyIcon: RawRepresentable, SendableCoded {
11+
public enum CartographyIcon: String, SendableCoded {
1212
/// The default or generic icon.
1313
///
1414
/// This icon might be represented differently depending on the context it's used in. For example, this might
@@ -29,54 +29,4 @@ public enum CartographyIcon: RawRepresentable, SendableCoded {
2929

3030
/// An icon that displays bubbles surrounded by sparkles.
3131
case sparklyBubbles
32-
33-
/// An icon that displays a single emoji character.
34-
///
35-
/// > Important: When creating an icon from ``init(rawValue:)``, strings that don't contain emojis or only contain
36-
/// > partial emojis are discounted.
37-
case emoji(String)
38-
39-
public init?(rawValue: String) {
40-
switch rawValue {
41-
case "default":
42-
self = .default
43-
case "home":
44-
self = .home
45-
case "building":
46-
self = .building
47-
case "sparklyBubbles":
48-
self = .sparklyBubbles
49-
case "town":
50-
self = .town
51-
case "book":
52-
self = .book
53-
case rawValue where rawValue.isEmoji:
54-
self = .emoji(rawValue)
55-
default:
56-
return nil
57-
}
58-
}
59-
60-
public var rawValue: String {
61-
switch self {
62-
case .default: "default"
63-
case .home: "home"
64-
case .building: "building"
65-
case .sparklyBubbles: "sparklyBubbles"
66-
case .town: "town"
67-
case .book: "book"
68-
case .emoji(let emojiString): emojiString
69-
}
70-
}
71-
}
72-
73-
extension String {
74-
var isEmoji: Bool {
75-
unicodeScalars.allSatisfy { scalar in
76-
scalar.properties.isEmoji
77-
|| scalar.properties.isEmojiModifier
78-
|| scalar.properties.isEmojiPresentation
79-
|| scalar.properties.isEmojiModifierBase
80-
}
81-
}
8232
}

Tests/MCMapTests/CartographyIconTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,12 @@ struct CartographyIconTests {
1515
let defaultIcon = CartographyIcon(rawValue: "default")
1616
#expect(defaultIcon == .default)
1717

18-
let emojiIcon = CartographyIcon(rawValue: "🚗")
19-
#expect(emojiIcon == .emoji("🚗"))
20-
2118
let noIcon = CartographyIcon(rawValue: "foo")
2219
#expect(noIcon == nil)
2320
}
2421

2522
@Test func decodeToRawValue() async throws {
2623
let defaultIcon = CartographyIcon.default
2724
#expect(defaultIcon.rawValue == "default")
28-
29-
let emojiIcon = CartographyIcon.emoji("🚗")
30-
#expect(emojiIcon.rawValue == "🚗")
3125
}
3226
}

0 commit comments

Comments
 (0)