mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Better handling for numeric emojis
This commit is contained in:
parent
dcd061eece
commit
d06dd5e8ba
3 changed files with 22 additions and 9 deletions
|
|
@ -93,11 +93,24 @@ extension String {
|
|||
|
||||
// Filter out variation selectors from the string
|
||||
var withoutVariationSelectors: String {
|
||||
return self.unicodeScalars
|
||||
.filter { scalar in
|
||||
return !scalar.properties.isVariationSelector
|
||||
var scalars: [UnicodeScalar] = []
|
||||
var previousWasASCII = false
|
||||
|
||||
for scalar in self.unicodeScalars {
|
||||
if scalar.properties.isVariationSelector {
|
||||
// Only keep variation selector if the previous character was ASCII
|
||||
if previousWasASCII {
|
||||
scalars.append(scalar)
|
||||
}
|
||||
// No need to update previousWasASCII since variation selectors aren't characters
|
||||
// Shouldn't have 2 in a row
|
||||
} else {
|
||||
scalars.append(scalar)
|
||||
previousWasASCII = scalar.isASCII
|
||||
}
|
||||
.compactMap { UnicodeScalar($0) }
|
||||
}
|
||||
|
||||
return scalars.compactMap { UnicodeScalar($0) }
|
||||
.map { String($0) }
|
||||
.joined()
|
||||
}
|
||||
|
|
@ -106,7 +119,7 @@ extension String {
|
|||
// Looks ahead to make sure that the variation selector is not already applied.
|
||||
var addingVariationSelectors: String {
|
||||
var result = ""
|
||||
var scalars = self.unicodeScalars
|
||||
let scalars = self.unicodeScalars
|
||||
var index = scalars.startIndex
|
||||
while index < scalars.endIndex {
|
||||
let currentScalar = scalars[index]
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ struct Connect: View {
|
|||
#endif
|
||||
Text("Num: \(String(node!.num))")
|
||||
Text("Short Name: \(node?.user?.shortName ?? "?")")
|
||||
Text("Long Name: \(node?.user?.longName ?? "unknown".localized)")
|
||||
Text("Long Name: \(node?.user?.longName?.addingVariationSelectors ?? "unknown".localized)")
|
||||
Text("BLE RSSI: \(connectedPeripheral.rssi)")
|
||||
|
||||
Button {
|
||||
|
|
@ -333,7 +333,7 @@ struct Connect: View {
|
|||
let localStats = node?.telemetries?.filtered(using: NSPredicate(format: "metricsType == 4"))
|
||||
let mostRecent = localStats?.lastObject as? TelemetryEntity
|
||||
|
||||
let activityAttributes = MeshActivityAttributes(nodeNum: Int(node?.num ?? 0), name: node?.user?.longName ?? "unknown")
|
||||
let activityAttributes = MeshActivityAttributes(nodeNum: Int(node?.num ?? 0), name: node?.user?.longName?.addingVariationSelectors ?? "unknown")
|
||||
|
||||
let future = Date(timeIntervalSinceNow: Double(timerSeconds))
|
||||
let initialContentState = MeshActivityAttributes.ContentState(uptimeSeconds: UInt32(mostRecent?.uptimeSeconds ?? 0),
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ struct Settings: View {
|
|||
/// Connected Node
|
||||
if node.num == bleManager.connectedPeripheral?.num ?? 0 {
|
||||
Label {
|
||||
Text("BLE: \(node.user?.longName ?? "unknown".localized)")
|
||||
Text("BLE: \(node.user?.longName?.addingVariationSelectors ?? "unknown".localized)")
|
||||
} icon: {
|
||||
Image(systemName: "antenna.radiowaves.left.and.right")
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ struct Settings: View {
|
|||
.tag(Int(node.num))
|
||||
} else if !UserDefaults.enableAdministration {
|
||||
Label {
|
||||
Text("Request Legacy Admin: \(node.user?.longName ?? "unknown".localized)")
|
||||
Text("Request Legacy Admin: \(node.user?.longName?.addingVariationSelectors ?? "unknown".localized)")
|
||||
} icon: {
|
||||
Image(systemName: "rectangle.and.hand.point.up.left")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue