File tree 4 files changed +14
-0
lines changed
4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ interface SendBirdProviderProps {
53
53
userId: string;
54
54
appId: string;
55
55
accessToken?: string;
56
+ configureSession?: (sdk: SendBird.SendBirdInstance) => SendBird.SessionHandler;
56
57
children?: React.ReactNode;
57
58
theme?: 'light' | 'dark';
58
59
nickname?: string;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ interface SendBirdProviderProps {
59
59
userId : string ;
60
60
appId : string ;
61
61
accessToken ?: string ;
62
+ configureSession ?: ( sdk : SendBird . SendBirdInstance ) => SendBird . SessionHandler ;
62
63
children ?: React . ReactNode ;
63
64
theme ?: 'light' | 'dark' ;
64
65
nickname ?: string ;
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export default function Sendbird(props) {
28
28
dateLocale,
29
29
appId,
30
30
accessToken,
31
+ configureSession,
31
32
children,
32
33
disableUserProfile,
33
34
renderUserProfile,
@@ -71,6 +72,7 @@ export default function Sendbird(props) {
71
72
sdkStore,
72
73
nickname,
73
74
profileUrl,
75
+ configureSession,
74
76
sdk : sdkStore . sdk ,
75
77
logger,
76
78
} , {
@@ -192,6 +194,7 @@ Sendbird.propTypes = {
192
194
userId : PropTypes . string . isRequired ,
193
195
appId : PropTypes . string . isRequired ,
194
196
accessToken : PropTypes . string ,
197
+ configureSession : PropTypes . func ,
195
198
children : PropTypes . oneOfType ( [
196
199
PropTypes . element ,
197
200
PropTypes . arrayOf ( PropTypes . element ) ,
@@ -241,6 +244,7 @@ Sendbird.propTypes = {
241
244
242
245
Sendbird . defaultProps = {
243
246
accessToken : '' ,
247
+ configureSession : null ,
244
248
theme : 'light' ,
245
249
nickname : '' ,
246
250
dateLocale : null ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export const handleConnection = ({
40
40
nickname,
41
41
profileUrl,
42
42
accessToken,
43
+ configureSession,
43
44
sdk,
44
45
logger,
45
46
} , dispatchers ) => {
@@ -54,9 +55,13 @@ export const handleConnection = ({
54
55
logger,
55
56
onDisconnect : ( ) => {
56
57
logger . info ( 'Setup connection' ) ;
58
+ let sessionHandler = null ;
57
59
sdkDispatcher ( { type : SET_SDK_LOADING , payload : true } ) ;
58
60
if ( userId && appId ) {
59
61
const newSdk = new Sb ( { appId } ) ;
62
+ if ( configureSession && typeof configureSession === 'function' ) {
63
+ sessionHandler = configureSession ( newSdk ) ;
64
+ }
60
65
// to check if code is released version from rollup and *not from storybook*
61
66
// see rollup config file
62
67
if ( IS_ROLLUP === IS_ROLLUP_REPLACE ) {
@@ -89,6 +94,9 @@ export const handleConnection = ({
89
94
. then ( ( res ) => connectCbSucess ( res ) )
90
95
. catch ( ( err ) => connectCbError ( err ) ) ;
91
96
} else {
97
+ if ( sessionHandler ) {
98
+ newSdk . setSessionHandler ( sessionHandler ) ;
99
+ }
92
100
newSdk . connect ( userId )
93
101
. then ( ( res ) => connectCbSucess ( res ) )
94
102
. catch ( ( err ) => connectCbError ( err ) ) ;
You can’t perform that action at this time.
0 commit comments