Fix max device name chars

This commit is contained in:
Leon Böttger committed 2025-12-26 13:42:46 +01:00
1 parent 728385ff95
commit a9e6ed1ddf
3 files changed
+23 -19

No files matched your search

@@ -44,7 +44,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
private static let customDeviceNameKey = "com.leonboettger.quickdrop.deviceName"
public let endpointID: [UInt8] = generateEndpointID()
public static let maxNameChars = 31
public static let shared = NearbyConnectionManager()
@@ -151,13 +150,13 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
let deviceType = isMac() ? RemoteDeviceInfo.DeviceType.computer : (isiPadOrMac() ? .tablet : .phone)
if let customName = getCustomDeviceName() {
return EndpointInfo(name: String(customName.prefix(Self.maxNameChars)), deviceType: deviceType)
return EndpointInfo(name: String(customName), deviceType: deviceType)
}
#if os(macOS)
return EndpointInfo(name: String((Host.current().localizedName ?? "Mac").prefix(Self.maxNameChars)), deviceType: deviceType)
return EndpointInfo(name: String((Host.current().localizedName ?? "Mac")), deviceType: deviceType)
#else
return EndpointInfo(name: String(Device.current.description.withoutBracketedContent.prefix(Self.maxNameChars)), deviceType: deviceType)
return EndpointInfo(name: String(Device.current.description.withoutBracketedContent), deviceType: deviceType)
#endif
}