@@ -68,32 +68,33 @@ export type ThreadReadState<SCG extends ExtendableGenerics = DefaultGenerics> =
68
68
const DEFAULT_PAGE_LIMIT = 50 ;
69
69
const DEFAULT_SORT : { created_at : AscDesc } [ ] = [ { created_at : - 1 } ] ;
70
70
const MARK_AS_READ_THROTTLE_TIMEOUT = 1000 ;
71
- const THREAD_RESERVED_KEYS = [
72
- 'channel' ,
73
- 'channel_cid' ,
74
- 'created_at' ,
75
- 'created_by_user_id' ,
76
- 'parent_message_id' ,
77
- 'title' ,
78
- 'updated_at' ,
79
- 'latest_replies' ,
80
- 'active_participant_count' ,
81
- 'deleted_at' ,
82
- 'last_message_at' ,
83
- 'participant_count' ,
84
- 'reply_count' ,
85
- 'read' ,
86
- 'thread_participants' ,
87
- 'created_by' ,
88
- 'parent_message' ,
89
- ] as const ;
71
+ // TODO: remove this once we move to API v2
72
+ export const THREAD_RESPONSE_RESERVED_KEYS : Record < keyof ThreadResponse , true > = {
73
+ channel : true ,
74
+ channel_cid : true ,
75
+ created_at : true ,
76
+ created_by_user_id : true ,
77
+ parent_message_id : true ,
78
+ title : true ,
79
+ updated_at : true ,
80
+ latest_replies : true ,
81
+ active_participant_count : true ,
82
+ deleted_at : true ,
83
+ last_message_at : true ,
84
+ participant_count : true ,
85
+ reply_count : true ,
86
+ read : true ,
87
+ thread_participants : true ,
88
+ created_by : true ,
89
+ parent_message : true ,
90
+ } ;
90
91
91
92
// TODO: remove this once we move to API v2
92
- const constructCustomDataObject = < SCG extends ExtendableGenerics > ( threadData : ThreadResponse < SCG > ) => {
93
+ const constructCustomDataObject = < T extends ThreadResponse > ( threadData : T ) => {
93
94
const custom : ThreadResponseCustomData = { } ;
94
95
95
96
for ( const key in threadData ) {
96
- if ( THREAD_RESERVED_KEYS . includes ( key as keyof ThreadResponse < SCG > ) ) {
97
+ if ( THREAD_RESPONSE_RESERVED_KEYS [ key as keyof ThreadResponse ] ) {
97
98
continue ;
98
99
}
99
100
@@ -145,7 +146,7 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
145
146
replyCount : threadData . reply_count ?? 0 ,
146
147
updatedAt : threadData . updated_at ? new Date ( threadData . updated_at ) : null ,
147
148
title : threadData . title ,
148
- custom : constructCustomDataObject < SCG > ( threadData ) ,
149
+ custom : constructCustomDataObject ( threadData ) ,
149
150
} ) ;
150
151
151
152
this . id = threadData . parent_message_id ;
@@ -253,7 +254,7 @@ export class Thread<SCG extends ExtendableGenerics = DefaultGenerics> {
253
254
updatedAt : new Date ( threadData . updated_at ) ,
254
255
deletedAt : threadData . deleted_at ? new Date ( threadData . deleted_at ) : null ,
255
256
// TODO: use threadData.custom once we move to API v2
256
- custom : constructCustomDataObject < SCG > ( threadData ) ,
257
+ custom : constructCustomDataObject ( threadData ) ,
257
258
} ) ;
258
259
} ) . unsubscribe ;
259
260
} ;
0 commit comments