Skip to content

Commit

Permalink
Rename it to channel role because role is taken by the user list filt…
Browse files Browse the repository at this point in the history
…ering
  • Loading branch information
laevandus committed Dec 18, 2024
1 parent b5b91b1 commit 8e08dac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/StreamChat/Query/ChannelMemberListQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public extension FilterKey where Scope: AnyMemberListFilterScope {
/// Supported operators: `equal`, `in`, `autocomplete`
static var email: FilterKey<Scope, String> { "user.email" }

/// Filter key matching the role of the user
/// Filter key matching the channel role of the user
/// Supported operators: `equal`
static var role: FilterKey<Scope, MemberRole> { "channel_role" }
static var channelRole: FilterKey<Scope, MemberRole> { "channel_role" }

/// Filter key matching the banned status
/// Supported operators: `equal`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public enum ChannelMemberListSortingKey: String, SortingKey {
/// - Warning: This option is heavy for the backend and can slow down API requests' response time. If there's no explicit requirement for this sorting option consider using a different one.
case name = "user.name"

/// Sort channel members by their role (`channel_role`).
case role = "channelRoleRaw"
/// Sort channel members by their channel role.
case channelRole = "channelRoleRaw"

public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
let value: String

switch self {
case .channelRole: value = "channel_role"
case .createdAt: value = "created_at"
case .name: value = "name"
case .role: value = "channel_role"
case .userId: value = "user_id"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ final class ChannelMemberListSortingKey_Tests: XCTestCase {
func test_sortDescriptor_keyPaths_areValid() throws {
// Put all `ChannelMemberListSortingKey`s in an array
// We don't use `CaseIterable` since we only need this for tests
let sortingKeys: [ChannelMemberListSortingKey] = [.createdAt, .name, .role, .userId]
let sortingKeys: [ChannelMemberListSortingKey] = [.createdAt, .name, .channelRole, .userId]

// Iterate over keys...
for key in sortingKeys {
Expand All @@ -24,7 +24,7 @@ final class ChannelMemberListSortingKey_Tests: XCTestCase {
ChannelMemberListSortingKey.name.rawValue,
NSExpression(forKeyPath: \MemberDTO.user.name).keyPath
)
case .role:
case .channelRole:
XCTAssertEqual(key.rawValue, KeyPath.string(\MemberDTO.channelRoleRaw))
case .userId:
XCTAssertEqual(key.rawValue, NSExpression(forKeyPath: \MemberDTO.user.id).keyPath)
Expand Down

0 comments on commit 8e08dac

Please sign in to comment.