File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed
src/smart-components/ChannelList Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import useSendbirdStateContext from '../../../../hooks/useSendbirdStateContext';
1515import EditUserProfile from '../../../EditUserProfile' ;
1616import PlaceHolder , { PlaceHolderTypes } from '../../../../ui/PlaceHolder' ;
1717
18+ const DELIVERY_RECIPT = 'delivery_receipt' ;
19+
1820interface RenderChannelPreviewProps {
1921 channel : SendBird . GroupChannel ;
2022 onLeaveChannel (
@@ -124,9 +126,18 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
124126 type : channelListActions . FETCH_CHANNELS_SUCCESS ,
125127 payload : channelList ,
126128 } ) ;
127- if ( channelList && typeof channelList . forEach === 'function' ) {
129+ const canSetMarkAsDelivered = sdk ?. appInfo ?. premiumFeatureList
130+ ?. find ( ( feature ) => ( feature === DELIVERY_RECIPT ) ) ;
131+
132+ if ( canSetMarkAsDelivered ) {
128133 logger . info ( 'ChannelList: Marking all channels as read' ) ;
129- channelList . forEach ( ( c ) => { sdk . markAsDelivered ( c . url ) } ) ;
134+ // eslint-disable-next-line no-unused-expressions
135+ channelList ?. forEach ( ( c , idx ) => {
136+ // Plan-based rate limits - minimum limit is 5 requests per second
137+ setTimeout ( ( ) => {
138+ sdk ?. markAsDelivered ( c ?. url ) ;
139+ } , 300 * idx ) ;
140+ } ) ;
130141 }
131142 } ) ;
132143 }
Original file line number Diff line number Diff line change 11import * as channelActions from './dux/actionTypes' ;
22import * as topics from '../../lib/pubSub/topics' ;
33
4+ const DELIVERY_RECIPT = 'delivery_receipt' ;
5+
46const createEventHandler = ( {
57 sdk,
68 sdkChannelHandlerId,
@@ -217,9 +219,19 @@ function setupChannelList({
217219 type : channelActions . INIT_CHANNELS_SUCCESS ,
218220 payload : sortedChannelList ,
219221 } ) ;
220- if ( channelList && typeof channelList . forEach === 'function' ) {
221- logger . info ( 'ChannelList - mark all channels as delivered' ) ;
222- channelList . forEach ( ( c ) => c . markAsDelivered ( ) ) ;
222+ const canSetMarkAsDelivered = sdk ?. appInfo ?. premiumFeatureList
223+ ?. find ( ( feature ) => ( feature === DELIVERY_RECIPT ) ) ;
224+
225+ if ( canSetMarkAsDelivered ) {
226+ logger . info ( 'ChannelList: Marking all channels as read' ) ;
227+ // eslint-disable-next-line no-unused-expressions
228+ channelList ?. forEach ( ( c , idx ) => {
229+ // Plan-based rate limits - minimum limit is 5 requests per second
230+ setTimeout ( ( ) => {
231+ // eslint-disable-next-line no-unused-expressions
232+ sdk ?. markAsDelivered ( c ?. url ) ;
233+ } , 300 * idx ) ;
234+ } ) ;
223235 }
224236 } ) ;
225237 } else {
You can’t perform that action at this time.
0 commit comments