File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
src/smart-components/ChannelList Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import { uuidv4 } from '../../utils/uuid';
2727import './index.scss' ;
2828
2929const noop = ( ) => { } ;
30+ const DELIVERY_RECIPT = 'delivery_receipt' ;
3031
3132function ChannelList ( props ) {
3233 const {
@@ -232,9 +233,20 @@ function ChannelList(props) {
232233 type : channelListActions . FETCH_CHANNELS_SUCCESS ,
233234 payload : channelList ,
234235 } ) ;
235- if ( channelList && typeof channelList . forEach === 'function' ) {
236+
237+ const canSetMarkAsDelivered = sdk ?. appInfo ?. premiumFeatureList
238+ ?. find ( ( feature ) => ( feature === DELIVERY_RECIPT ) ) ;
239+
240+ if ( canSetMarkAsDelivered ) {
236241 logger . info ( 'ChannelList: Marking all channels as read' ) ;
237- channelList . forEach ( ( c ) => c . markAsDelivered ( ) ) ;
242+ // eslint-disable-next-line no-unused-expressions
243+ channelList ?. forEach ( ( channel , idx ) => {
244+ // Plan-based rate limits - minimum limit is 5 requests per second
245+ setTimeout ( ( ) => {
246+ // eslint-disable-next-line no-unused-expressions
247+ channel ?. markAsDelivered ( ) ;
248+ } , 500 * idx ) ;
249+ } ) ;
238250 }
239251 } ) ;
240252 }
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' ;
45const createEventHandler = ( {
56 sdk,
67 sdkChannelHandlerId,
@@ -217,9 +218,18 @@ function setupChannelList({
217218 type : channelActions . INIT_CHANNELS_SUCCESS ,
218219 payload : sorted ,
219220 } ) ;
220- if ( channelList && typeof channelList . forEach === 'function' ) {
221- logger . info ( 'ChannelList - mark all channels as delivered' ) ;
222- channelList . forEach ( ( c ) => c . markAsDelivered ( ) ) ;
221+ const canSetMarkAsDelivered = sdk ?. appInfo ?. premiumFeatureList
222+ ?. find ( ( feature ) => ( feature === DELIVERY_RECIPT ) ) ;
223+ if ( canSetMarkAsDelivered ) {
224+ logger . info ( 'ChannelList: Marking all channels as read' ) ;
225+ // eslint-disable-next-line no-unused-expressions
226+ channelList ?. forEach ( ( channel , idx ) => {
227+ // Plan-based rate limits - minimum limit is 5 requests per second
228+ setTimeout ( ( ) => {
229+ // eslint-disable-next-line no-unused-expressions
230+ channel ?. markAsDelivered ( ) ;
231+ } , 500 * idx ) ;
232+ } ) ;
223233 }
224234 } ) ;
225235 } else {
You can’t perform that action at this time.
0 commit comments