Skip to content

Conversation

@arnautov-anton
Copy link
Contributor

Description of the changes, What, Why and How?

This PR allows integrators to decide how the target field should be asserted during sorting.

https://getstream.slack.com/archives/C06CF5TKRGA/p1767637494321509?thread_ts=1767298663.322459&cid=C06CF5TKRGA

const sort: ChannelSort = {
  member_count: { direction: -1, type: 'number' },
  has_unread: -1,
};

@arnautov-anton arnautov-anton requested a review from kanat January 6, 2026 12:42
| AscDesc
| {
direction: AscDesc;
type?: 'string' | 'number';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kanat what types will be supported?

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Size Change: -47 B (-0.01%)

Total Size: 356 kB

Filename Size Change
dist/cjs/index.browser.js 119 kB -15 B (-0.01%)
dist/cjs/index.node.js 120 kB -16 B (-0.01%)
dist/esm/index.mjs 118 kB -16 B (-0.01%)

compressed-size-action

sortFields.push({ field, direction });

export function normalizeQuerySort<T extends Sort<string>>(sort: T | T[]) {
const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | null }> =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | null }> =
const sortFields: Array<{ direction: AscDesc; field: keyof T; type: string | number | null }> =

Not sure, but basing it on this:

https://github.com/GetStream/stream-chat-js/pull/1673/changes#r2664806559

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is just a string in this case as it's supposed to be sent to the BE, TS should not remove this during compile time. In this case it's just generalized to string so I don't have to do "string" | "number" | "some-other-type-once-added" since we don't really care about specificity at that point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants