Skip to content

Commit 814d018

Browse files
committed
align with latest wprs
1 parent 8a00d3b commit 814d018

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

Modules/Sources/WordPressCore/Users/DisplayUser.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,15 @@ extension DisplayUser {
6969
.joined(separator: " ")
7070
}
7171
}
72+
73+
extension UserRole: @retroactive Codable {
74+
public init(from decoder: any Decoder) throws {
75+
let role = try decoder.singleValueContainer().decode(String.self)
76+
self.init(role)
77+
}
78+
79+
public func encode(to encoder: any Encoder) throws {
80+
var container = encoder.singleValueContainer()
81+
try container.encode(self.rawValue)
82+
}
83+
}

WordPress/Classes/Users/ViewModel/UserListViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class UserListViewModel: ObservableObject {
126126
}
127127

128128
private func sortUsers(_ users: [DisplayUser]) -> [Section] {
129-
Dictionary(grouping: users) { $0.id == currentUserId ? RoleSection.me : RoleSection.role($0.role) }
129+
Dictionary(grouping: users) { $0.id == currentUserId ? RoleSection.me : RoleSection.role($0.role.rawValue) }
130130
.map { Section(id: $0.key, users: $0.value.sorted(by: { $0.username < $1.username })) }
131131
.sorted { $0.id < $1.id }
132132
}

WordPress/Classes/Users/Views/UserDetailsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct UserDetailsView: View {
5555
.listRowInsets(.zero)
5656

5757
Section {
58-
makeRow(title: Strings.roleFieldTitle, content: user.role.displayString)
58+
makeRow(title: Strings.roleFieldTitle, content: user.role.rawValue)
5959
makeRow(title: Strings.emailAddressFieldTitle, content: user.emailAddress, link: user.emailAddress.asEmail())
6060
if let website = user.websiteUrl, !website.isEmpty {
6161
makeRow(title: Strings.websiteFieldTitle, content: website, link: URL(string: website))

0 commit comments

Comments
 (0)