@@ -11,9 +11,9 @@ extension UserDetail: ProfileDetailRepresentable, LocationRepresentable {}
11
11
12
12
public typealias Tag = String
13
13
14
- public struct UserDetail : Codable {
14
+ public struct UserDetail {
15
15
public var bio : String ?
16
- @ NullableArray public var bioLinks : [ URL ]
16
+ public var bioLinks : [ String ]
17
17
public let currentAvatarImageUrl : String ?
18
18
public let currentAvatarThumbnailImageUrl : String ?
19
19
public let displayName : String
@@ -34,6 +34,35 @@ public struct UserDetail: Codable {
34
34
public let lastActivity : Date
35
35
}
36
36
37
+ extension UserDetail : Codable {
38
+ public init ( from decoder: any Decoder ) throws {
39
+ let container = try decoder. container ( keyedBy: CodingKeys . self)
40
+ bio = try container. decodeIfPresent ( String . self, forKey: . bio)
41
+ bioLinks = try container. decodeIfPresent ( [ String ] . self, forKey: . bioLinks) ?? [ ]
42
+ currentAvatarImageUrl = try container. decodeIfPresent ( String . self, forKey: . currentAvatarImageUrl)
43
+ currentAvatarThumbnailImageUrl = try container. decodeIfPresent (
44
+ String . self,
45
+ forKey: . currentAvatarThumbnailImageUrl
46
+ )
47
+ displayName = try container. decode ( String . self, forKey: . displayName)
48
+ id = try container. decode ( String . self, forKey: . id)
49
+ isFriend = try container. decode ( Bool . self, forKey: . isFriend)
50
+ lastLogin = try container. decode ( Date . self, forKey: . lastLogin)
51
+ lastPlatform = try container. decode ( String . self, forKey: . lastPlatform)
52
+ profilePicOverride = try container. decodeIfPresent ( String . self, forKey: . profilePicOverride)
53
+ state = try container. decode ( User . State. self, forKey: . state)
54
+ status = try container. decode ( UserStatus . self, forKey: . status)
55
+ statusDescription = try container. decode ( String . self, forKey: . statusDescription)
56
+ tags = try container. decode ( [ Tag ] . self, forKey: . tags)
57
+ userIcon = try container. decodeIfPresent ( String . self, forKey: . userIcon)
58
+ location = try container. decode ( String . self, forKey: . location)
59
+ friendKey = try container. decode ( String . self, forKey: . friendKey)
60
+ dateJoined = try container. decode ( String . self, forKey: . dateJoined)
61
+ note = try container. decode ( String . self, forKey: . note)
62
+ lastActivity = try container. decode ( Date . self, forKey: . lastActivity)
63
+ }
64
+ }
65
+
37
66
public struct EditableUserInfo : Codable , Hashable {
38
67
public var bio : String
39
68
public var bioLinks : [ URL ]
@@ -43,9 +72,56 @@ public struct EditableUserInfo: Codable, Hashable {
43
72
44
73
public init ( detail: any ProfileDetailRepresentable ) {
45
74
self . bio = detail. bio ?? " "
46
- self . bioLinks = detail . bioLinks
75
+ self . bioLinks = [ ]
47
76
self . status = detail. status
48
77
self . statusDescription = detail. statusDescription
49
78
self . tags = detail. tags
50
79
}
51
80
}
81
+
82
+ //public struct Tag: Codable, Hashable {
83
+ // public let value: TagValue?
84
+ //
85
+ // public init(from decoder: any Decoder) throws {
86
+ // let container = try decoder.singleValueContainer()
87
+ // var someValue: TagValue?
88
+ // do {
89
+ // someValue = try container.decode(TagValue.self)
90
+ // } catch {
91
+ // someValue = try .other(try container.decode(String.self))
92
+ // }
93
+ // self.value = someValue
94
+ //
95
+ // // for debug
96
+ // switch self.value {
97
+ // case .systemAvatarAccess, .system_trust_basic, .system_world_access:
98
+ // print(value)
99
+ // default:
100
+ // break
101
+ // }
102
+ // }
103
+ //
104
+ // public func encode(to encoder: any Encoder) throws {
105
+ // var container = encoder.singleValueContainer()
106
+ // try container.encode(self.value)
107
+ // }
108
+ //}
109
+
110
+
111
+ //public enum Tag: String, Codable, Hashable {
112
+ // case systemAvatarAccess
113
+ // case system_trust_basic
114
+ // case system_world_access
115
+ // case unknown
116
+ //
117
+ // public init(from decoder: Decoder) throws {
118
+ // let container = try decoder.singleValueContainer()
119
+ // let rawValue = try container.decode(String.self)
120
+ // self = Tag(rawValue: rawValue) ?? .unknown
121
+ // }
122
+ //
123
+ // public func encode(to encoder: any Encoder) throws {
124
+ // var container = encoder.singleValueContainer()
125
+ // try container.encode(self.rawValue)
126
+ // }
127
+ //}
0 commit comments