Skip to content

Commit 2560ac0

Browse files
authored
Use helper for sort conversion (#34)
1 parent 24378a5 commit 2560ac0

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lib/stream-chat/client.rb

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require 'stream-chat/channel'
88
require 'stream-chat/errors'
99
require 'stream-chat/version'
10+
require 'stream-chat/util'
1011

1112
module StreamChat
1213
DEFAULT_BLOCKLIST = 'profanity_en_2020_v1'
@@ -166,26 +167,18 @@ def delete_message(message_id)
166167
end
167168

168169
def query_users(filter_conditions, sort: nil, **options)
169-
sort_fields = []
170-
sort&.each do |k, v|
171-
sort_fields << { "field": k, "direction": v }
172-
end
173170
params = options.merge({
174171
"filter_conditions": filter_conditions,
175-
"sort": sort_fields
172+
"sort": get_sort_fields(sort)
176173
})
177174
get('users', params: { "payload": params.to_json })
178175
end
179176

180177
def query_channels(filter_conditions, sort: nil, **options)
181178
params = { "state": true, "watch": false, "presence": false }
182-
sort_fields = []
183-
sort&.each do |k, v|
184-
sort_fields << { "field": k, "direction": v }
185-
end
186179
params = params.merge(options).merge({
187180
"filter_conditions": filter_conditions,
188-
"sort": sort_fields
181+
"sort": get_sort_fields(sort)
189182
})
190183
get('channels', params: { "payload": params.to_json })
191184
end

0 commit comments

Comments
 (0)