Skip to content

Commit f0ce5a2

Browse files
authored
feat: Add disableMarkAsDelivered props into the App and Sendbird comp (#326)
1 parent e9e5076 commit f0ce5a2

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

scripts/index_d_ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ declare module "SendbirdUIKitGlobal" {
5454
dateLocale?: Locale;
5555
allowProfileEdit?: boolean;
5656
disableUserProfile?: boolean;
57+
disableMarkAsDelivered?: boolean;
5758
showSearchIcon?: boolean;
5859
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
5960
onProfileEditSuccess?(user: User): void;
@@ -220,6 +221,7 @@ declare module "SendbirdUIKitGlobal" {
220221
profileUrl?: string;
221222
dateLocale?: Locale;
222223
disableUserProfile?: boolean;
224+
disableMarkAsDelivered?: boolean;
223225
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
224226
allowProfileEdit?: boolean;
225227
userListQuery?(): UserListQuery;
@@ -239,6 +241,7 @@ declare module "SendbirdUIKitGlobal" {
239241

240242
export interface SendBirdStateConfig {
241243
disableUserProfile: boolean;
244+
disableMarkAsDelivered: boolean;
242245
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactNode | React.ReactElement;
243246
allowProfileEdit: boolean;
244247
isOnline: boolean;

src/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ interface SendBirdProviderProps {
101101
profileUrl?: string;
102102
dateLocale?: Locale;
103103
disableUserProfile?: boolean;
104+
disableMarkAsDelivered?: boolean;
104105
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
105106
allowProfileEdit?: boolean;
106107
userListQuery?(): UserListQuery;
@@ -119,6 +120,7 @@ interface SendBirdProviderProps {
119120

120121
interface SendBirdStateConfig {
121122
disableUserProfile: boolean;
123+
disableMarkAsDelivered: boolean;
122124
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
123125
allowProfileEdit: boolean;
124126
isOnline: boolean;
@@ -270,6 +272,7 @@ interface AppProps {
270272
dateLocale?: Locale;
271273
allowProfileEdit?: boolean;
272274
disableUserProfile?: boolean;
275+
disableMarkAsDelivered?: boolean;
273276
showSearchIcon?: boolean;
274277
renderUserProfile?: (props: RenderUserProfileProps) => React.ReactElement;
275278
onProfileEditSuccess?(user: User): void;

src/lib/Sendbird.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default function Sendbird(props) {
3434
customWebSocketHost,
3535
children,
3636
disableUserProfile,
37+
disableMarkAsDelivered,
3738
renderUserProfile,
3839
allowProfileEdit,
3940
theme,
@@ -174,6 +175,7 @@ export default function Sendbird(props) {
174175
},
175176
config: {
176177
disableUserProfile,
178+
disableMarkAsDelivered,
177179
renderUserProfile,
178180
allowProfileEdit,
179181
isOnline,
@@ -221,6 +223,7 @@ Sendbird.propTypes = {
221223
dateLocale: PropTypes.shape({}),
222224
profileUrl: PropTypes.string,
223225
disableUserProfile: PropTypes.bool,
226+
disableMarkAsDelivered: PropTypes.bool,
224227
renderUserProfile: PropTypes.func,
225228
allowProfileEdit: PropTypes.bool,
226229
userListQuery: PropTypes.func,
@@ -269,6 +272,7 @@ Sendbird.defaultProps = {
269272
dateLocale: null,
270273
profileUrl: '',
271274
disableUserProfile: false,
275+
disableMarkAsDelivered: false,
272276
renderUserProfile: null,
273277
allowProfileEdit: false,
274278
userListQuery: null,

src/lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface SendBirdProviderProps {
3333
profileUrl?: string;
3434
dateLocale?: Locale;
3535
disableUserProfile?: boolean;
36+
disableMarkAsDelivered?: boolean;
3637
renderUserProfile?: (props: SendBirdTypes.RenderUserProfileProps) => React.ReactElement;
3738
allowProfileEdit?: boolean;
3839
userListQuery?(): SendBirdTypes.UserListQuery;
@@ -51,6 +52,7 @@ export interface SendBirdProviderProps {
5152

5253
export interface SendBirdStateConfig {
5354
disableUserProfile: boolean;
55+
disableMarkAsDelivered: boolean;
5456
renderUserProfile?: (props: SendBirdTypes.RenderUserProfileProps) => React.ReactElement;
5557
allowProfileEdit: boolean;
5658
isOnline: boolean;

src/smart-components/App/index.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default function App(props) {
3636
stringSet,
3737
allowProfileEdit,
3838
disableUserProfile,
39+
disableMarkAsDelivered,
3940
renderUserProfile,
4041
showSearchIcon,
4142
onProfileEditSuccess,
@@ -66,6 +67,7 @@ export default function App(props) {
6667
config={config}
6768
colorSet={colorSet}
6869
disableUserProfile={disableUserProfile}
70+
disableMarkAsDelivered={disableMarkAsDelivered}
6971
renderUserProfile={renderUserProfile}
7072
imageCompression={imageCompression}
7173
isReactionEnabled={isReactionEnabled}
@@ -164,6 +166,7 @@ App.propTypes = {
164166
profileUrl: PropTypes.string,
165167
allowProfileEdit: PropTypes.bool,
166168
disableUserProfile: PropTypes.bool,
169+
disableMarkAsDelivered: PropTypes.bool,
167170
renderUserProfile: PropTypes.func,
168171
onProfileEditSuccess: PropTypes.func,
169172
dateLocale: PropTypes.shape({}),
@@ -210,6 +213,7 @@ App.defaultProps = {
210213
allowProfileEdit: false,
211214
onProfileEditSuccess: null,
212215
disableUserProfile: false,
216+
disableMarkAsDelivered: false,
213217
showSearchIcon: false,
214218
renderUserProfile: null,
215219
config: {},

src/smart-components/ChannelList/components/ChannelListUI/index.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
6666

6767
const sdkStore = state?.stores?.sdkStore;
6868
const config = state?.config;
69-
70-
const isOnline = state?.config?.isOnline;
71-
const logger = config?.logger;
69+
const {
70+
logger = null,
71+
isOnline = false,
72+
disableMarkAsDelivered = false,
73+
} = config;
7274

7375
const sdk = sdkStore?.sdk as SendbirdGroupChat;
7476
const sdkError = sdkStore?.error;
@@ -78,7 +80,7 @@ const ChannelListUI: React.FC<ChannelListUIProps> = (props: ChannelListUIProps)
7880
useEffect(() => {
7981
// https://stackoverflow.com/a/60907638
8082
let isMounted = true;
81-
if (channelsTomarkAsRead?.length > 0) {
83+
if (channelsTomarkAsRead?.length > 0 && !disableMarkAsDelivered) {
8284
channelsTomarkAsRead?.forEach((c, idx) => {
8385
// Plan-based rate limits - minimum limit is 5 requests per second
8486
setTimeout(() => {

src/smart-components/ChannelList/context/ChannelListProvider.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ const ChannelListProvider: React.FC<ChannelListProviderProps> = (props: ChannelL
150150
const { sdkStore } = stores;
151151
const { pubSub, logger } = config;
152152
const {
153-
isTypingIndicatorEnabledOnChannelList,
154-
isMessageReceiptStatusEnabledOnChannelList,
153+
disableMarkAsDelivered = false,
154+
isTypingIndicatorEnabledOnChannelList = false,
155+
isMessageReceiptStatusEnabledOnChannelList = false,
155156
} = config;
156157
const sdk = sdkStore?.sdk as SendbirdGroupChat;
157158

@@ -179,7 +180,7 @@ const ChannelListProvider: React.FC<ChannelListProviderProps> = (props: ChannelL
179180
useEffect(() => {
180181
// https://stackoverflow.com/a/60907638
181182
let isMounted = true;
182-
if (channelsTomarkAsRead?.length > 0) {
183+
if (channelsTomarkAsRead?.length > 0 && !disableMarkAsDelivered) {
183184
channelsTomarkAsRead?.forEach((c, idx) => {
184185
// Plan-based rate limits - minimum limit is 5 requests per second
185186
setTimeout(() => {

0 commit comments

Comments
 (0)