Skip to content

Commit c0a1492

Browse files
nickfil22jwatzman
authored andcommitted
Moving the resolvedStatus within the ThreadListFilter type
When adding the `resolvedStatus` to the LocationData API, I noticed that it wasn't relevant to the ThreadList, as the ThreadList doesn't have pagination and fetches all threads anyway - doing all filtering within the component. So I created a union type. This is not great 1. because it doesn't enforce consistency in our API filters, and 2. because the docs look bad (I had not noticed). TsDoc can't handle union types and it's a known bug (microsoft/tsdoc#164). This PR moves the `resolvedStatus` within the ThreadListFilter type, then goes through all its uses and decides on whether to omit it or not. Test Plan: Tested ThreadedComments with all 4 tab options and they worked correctly. Then tested the ThreadedComments by switching the underlying API to use the deprecated parameter, which also worked as expected. Also, docs look really nice again :) Reviewers: flooey, jwatzman, km-nur Reviewed By: km-nur Pull Request: https://github.com/getcord/monorepo/pull/6436 monorepo-commit: e8a3e6ed8846cff9baeffc16e7e1dabdb7e42cb7
1 parent bb807fd commit c0a1492

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

packages/react/components/ThreadList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type ThreadListReactComponentProps = PropsWithFlags<
2626
showScreenshotPreviewInMessage?: boolean;
2727
highlightOpenFloatingThread?: boolean;
2828
highlightThreadId?: string;
29-
filter?: ThreadListFilter;
29+
filter?: Omit<ThreadListFilter, 'resolvedStatus'>;
3030
showPlaceholder?: boolean;
3131
partialMatch?: boolean;
3232
onThreadClick?: (

packages/types/thread.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export interface ThreadObserverOptions {
287287
export type ObserveThreadSummaryOptions = ThreadObserverOptions;
288288
export type ObserveThreadDataOptions = ThreadObserverOptions;
289289

290+
export type ResolvedStatus = 'any' | 'resolved' | 'unresolved';
290291
export type ThreadListFilter = {
291292
/**
292293
* The value for a `metadata` entry should be an object representing the
@@ -304,12 +305,19 @@ export type ThreadListFilter = {
304305
* @privateRemarks hidden
305306
*/
306307
organizationID?: string;
308+
/**
309+
* If set to `resolved`, only resolved threads will be returned. If set to `unresolved`,
310+
* only unresolved threads will be returned. If set to `any`, both resolved and
311+
* unresolved threads will be returned.
312+
*
313+
* If unset, defaults to `unresolved`.
314+
*/
315+
resolvedStatus?: ResolvedStatus;
307316
};
308317
export type SortDirection = 'ascending' | 'descending';
309318
export type SortBy =
310319
| 'first_message_timestamp'
311320
| 'most_recent_message_timestamp';
312-
export type ResolvedStatus = 'any' | 'resolved' | 'unresolved';
313321
export type ObserveLocationDataOptions = {
314322
/**
315323
* This option controls the criteria for how threads are sorted.
@@ -367,16 +375,7 @@ export type ObserveLocationDataOptions = {
367375
/**
368376
* An object that can be used to filter the threads returned.
369377
*/
370-
filter?: ThreadListFilter & {
371-
/**
372-
* If set to `resolved`, only resolved threads will be returned. If set to `unresolved`,
373-
* only unresolved threads will be returned. If set to `any`, both resolved and
374-
* unresolved threads will be returned.
375-
*
376-
* If unset, defaults to `unresolved`.
377-
*/
378-
resolvedStatus?: ResolvedStatus;
379-
};
378+
filter?: ThreadListFilter;
380379
};
381380

382381
export type LocationData = PaginationParams & {

0 commit comments

Comments
 (0)