@sendbird/uikit-react-native 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/contexts/SendbirdChat.js +1 -1
- package/lib/commonjs/contexts/SendbirdChat.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/contexts/SendbirdChat.js +1 -1
- package/lib/module/contexts/SendbirdChat.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +5 -5
- package/src/contexts/SendbirdChat.tsx +1 -1
- package/src/version.ts +1 -1
|
@@ -63,7 +63,7 @@ const SendbirdChatProvider = _ref => {
|
|
|
63
63
|
(0, _react.useEffect)(() => {
|
|
64
64
|
const listener = status => {
|
|
65
65
|
// 'active' | 'background' | 'inactive' | 'unknown' | 'extension';
|
|
66
|
-
if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();else sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
66
|
+
if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();else if (status === 'background') sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
const subscriber = _reactNative.AppState.addEventListener('change', listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SendbirdChatContext","React","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","useState","forceUpdate","useForceUpdate","appFeatures","useAppFeatures","setCurrentUser","useCallback","user","updateCurrentUserInfo","nickname","profile","Error","profileUrl","updateCurrentUserInfoWithProfileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","unreadMessageCount","markAsDelivered","url","useEffect","listener","status","getConnectionState","setForegroundState","setBackgroundState","subscriber","AppState","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChat.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type { SendbirdChatSDK, SendbirdGroupChannel, SendbirdUser } from '@sendbird/uikit-utils';\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n if (typeof profile === 'undefined') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, sdkInstance.currentUser.profileUrl);\n } else if (typeof profile === 'string') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, profile);\n } else if (typeof profile === 'object') {\n user = await sdkInstance.updateCurrentUserInfoWithProfileImage(nickname, profile);\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled && channel.unreadMessageCount > 0) {\n sdkInstance.markAsDelivered(channel.url);\n }\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();\n else sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdCh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A5D,CAAb;IACD,CAFM,MAEA;MACL,MAAM,IAAIC,KAAJ,CAAW,qDAAoD,OAAOD,OAAQ,GAA9E,CAAN;IACD;;IAEDL,cAAc,CAACE,IAAD,CAAd;IACA,OAAOA,IAAP;EACD,CAlB6D,EAmB9D,CAACb,WAAD,EAAcI,WAAd,EAA2BO,cAA3B,CAnB8D,CAAhE;EAsBA,MAAMS,0BAAiE,GAAG,IAAAR,kBAAA,EACvES,OAAD,IAAmC;IACjC,IAAIZ,WAAW,CAACa,sBAAZ,IAAsCD,OAAO,CAACE,kBAAR,GAA6B,CAAvE,EAA0E;MACxEvB,WAAW,CAACwB,eAAZ,CAA4BH,OAAO,CAACI,GAApC;IACD;EACF,CALuE,EAMxE,CAACzB,WAAD,EAAcS,WAAW,CAACa,sBAA1B,CANwE,CAA1E;EASA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,QAAQ,GAAIC,MAAD,IAA4B;MAC3C;MACA,IAAIA,MAAM,KAAK,QAAf,EAAyB5B,WAAW,CAAC6B,kBAAZ,OAAqC,QAArC,IAAiD7B,WAAW,CAAC8B,kBAAZ,EAAjD,CAAzB,
|
|
1
|
+
{"version":3,"names":["SendbirdChatContext","React","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","useState","forceUpdate","useForceUpdate","appFeatures","useAppFeatures","setCurrentUser","useCallback","user","updateCurrentUserInfo","nickname","profile","Error","profileUrl","updateCurrentUserInfoWithProfileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","unreadMessageCount","markAsDelivered","url","useEffect","listener","status","getConnectionState","setForegroundState","setBackgroundState","subscriber","AppState","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChat.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type { SendbirdChatSDK, SendbirdGroupChannel, SendbirdUser } from '@sendbird/uikit-utils';\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n if (typeof profile === 'undefined') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, sdkInstance.currentUser.profileUrl);\n } else if (typeof profile === 'string') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, profile);\n } else if (typeof profile === 'object') {\n user = await sdkInstance.updateCurrentUserInfoWithProfileImage(nickname, profile);\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled && channel.unreadMessageCount > 0) {\n sdkInstance.markAsDelivered(channel.url);\n }\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();\n else if (status === 'background') sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdChatContext.Provider value={value}>{children}</SendbirdChatContext.Provider>;\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;;;AAmCO,MAAMA,mBAAmB,gBAAGC,cAAA,CAAMC,aAAN,CAAoC,IAApC,CAA5B;;;;AACA,MAAMC,oBAAoB,GAAG,QAMvB;EAAA,IANwB;IACnCC,QADmC;IAEnCC,WAFmC;IAGnCC,+BA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AG,IAAAR,kBAAA,EACvES,OAAD,IAAmC;IACjC,IAAIZ,WAAW,CAACa,sBAAZ,IAAsCD,OAAO,CAACE,kBAAR,GAA6B,CAAvE,EAA0E;MACxEvB,WAAW,CAACwB,eAAZ,CAA4BH,OAAO,CAACI,GAApC;IACD;EACF,CALuE,EAMxE,CAACzB,WAAD,EAAcS,WAAW,CAACa,sBAA1B,CANwE,CAA1E;EASA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,QAAQ,GAAIC,MAAD,IAA4B;MAC3C;MACA,IAAIA,MAAM,KAAK,QAAf,EAAyB5B,WAAW,CAAC6B,kBAAZ,OAAqC,QAArC,IAAiD7B,WAAW,CAAC8B,kBAAZ,EAAjD,CAAzB,KACK,IAAIF,MAAM,KAAK,YAAf,EAA6B5B,WAAW,CAAC6B,kBAAZ,OAAqC,MAArC,IAA+C7B,WAAW,CAAC+B,kBAAZ,EAA/C;IACnC,CAJD;;IAMA,MAAMC,UAAU,GAAGC,qBAAA,CAASC,gBAAT,CAA0B,QAA1B,EAAoCP,QAApC,CAAnB;;IACA,OAAO,MAAMK,UAAU,CAACG,MAAX,EAAb;EACD,CATD,EASG,CAACnC,WAAD,CATH;EAWA,MAAMoC,KAAc,GAAG;IACrBC,GAAG,EAAErC,WADgB;IAErBI,WAFqB;IAGrBO,cAHqB;IAKrBG,qBALqB;IAMrBM,0BANqB;IAQrBkB,QAAQ,EAAE,EACR,GAAG7B,WADK;MAER8B,gCAAgC,EAAEtC,+BAF1B;MAGRuC,iCAAiC,EAAErC,gCAH3B;MAIRsC,sCAAsC,EAAEvC;IAJhC;EARW,CAAvB;EAgBA,oBAAO,6BAAC,mBAAD,CAAqB,QAArB;IAA8B,KAAK,EAAEkC;EAArC,GAA6CrC,QAA7C,CAAP;AACD,CA5EM"}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '1.1.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '1.1.3';\nexport default VERSION;\n"],"mappings":";;;;;;AAAA,MAAMA,OAAO,GAAG,OAAhB;eACeA,O"}
|
|
@@ -45,7 +45,7 @@ export const SendbirdChatProvider = _ref => {
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
const listener = status => {
|
|
47
47
|
// 'active' | 'background' | 'inactive' | 'unknown' | 'extension';
|
|
48
|
-
if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();else sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
48
|
+
if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();else if (status === 'background') sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const subscriber = AppState.addEventListener('change', listener);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useState","AppState","useAppFeatures","useForceUpdate","SendbirdChatContext","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","forceUpdate","appFeatures","setCurrentUser","user","updateCurrentUserInfo","nickname","profile","Error","profileUrl","updateCurrentUserInfoWithProfileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","unreadMessageCount","markAsDelivered","url","listener","status","getConnectionState","setForegroundState","setBackgroundState","subscriber","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChat.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type { SendbirdChatSDK, SendbirdGroupChannel, SendbirdUser } from '@sendbird/uikit-utils';\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n if (typeof profile === 'undefined') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, sdkInstance.currentUser.profileUrl);\n } else if (typeof profile === 'string') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, profile);\n } else if (typeof profile === 'object') {\n user = await sdkInstance.updateCurrentUserInfoWithProfileImage(nickname, profile);\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled && channel.unreadMessageCount > 0) {\n sdkInstance.markAsDelivered(channel.url);\n }\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();\n else sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdChatContext.Provider value={value}>{children}</SendbirdChatContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,QAAxC,QAAwD,OAAxD;AACA,SAASC,QAAT,QAAyC,cAAzC;AAEA,SAASC,cAAT,QAA+B,4BAA/B;AAEA,SAASC,cAAT,QAA+B,uBAA/B;AAmCA,OAAO,MAAMC,mBAAmB,gBAAGP,KAAK,CAACQ,aAAN,CAAoC,IAApC,CAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,QAMvB;EAAA,IANwB;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,0BAAiE,GAAG1B,WAAW,CAClF2B,OAAD,IAAmC;IACjC,IAAIV,WAAW,CAACW,sBAAZ,IAAsCD,OAAO,CAACE,kBAAR,GAA6B,CAAvE,EAA0E;MACxEnB,WAAW,CAACoB,eAAZ,CAA4BH,OAAO,CAACI,GAApC;IACD;EACF,CALkF,EAMnF,CAACrB,WAAD,EAAcO,WAAW,CAACW,sBAA1B,CANmF,CAArF;EASA3B,SAAS,CAAC,MAAM;IACd,MAAM+B,QAAQ,GAAIC,MAAD,IAA4B;MAC3C;MACA,IAAIA,MAAM,KAAK,QAAf,EAAyBvB,WAAW,CAACwB,kBAAZ,OAAqC,QAArC,IAAiDxB,WAAW,CAACyB,kBAAZ,EAAjD,CAAzB,
|
|
1
|
+
{"version":3,"names":["React","useCallback","useEffect","useState","AppState","useAppFeatures","useForceUpdate","SendbirdChatContext","createContext","SendbirdChatProvider","children","sdkInstance","enableAutoPushTokenRegistration","enableChannelListMessageReceiptStatus","enableChannelListTypingIndicator","currentUser","_setCurrentUser","forceUpdate","appFeatures","setCurrentUser","user","updateCurrentUserInfo","nickname","profile","Error","profileUrl","updateCurrentUserInfoWithProfileImage","markAsDeliveredWithChannel","channel","deliveryReceiptEnabled","unreadMessageCount","markAsDelivered","url","listener","status","getConnectionState","setForegroundState","setBackgroundState","subscriber","addEventListener","remove","value","sdk","features","autoPushTokenRegistrationEnabled","channelListTypingIndicatorEnabled","channelListMessageReceiptStatusEnabled"],"sources":["SendbirdChat.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { AppState, AppStateStatus } from 'react-native';\n\nimport { useAppFeatures } from '@sendbird/uikit-chat-hooks';\nimport type { SendbirdChatSDK, SendbirdGroupChannel, SendbirdUser } from '@sendbird/uikit-utils';\nimport { useForceUpdate } from '@sendbird/uikit-utils';\n\nimport type { FileType } from '../platform/types';\n\ntype Props = React.PropsWithChildren<{\n sdkInstance: SendbirdChatSDK;\n\n enableAutoPushTokenRegistration: boolean;\n enableChannelListTypingIndicator: boolean;\n enableChannelListMessageReceiptStatus: boolean;\n}>;\n\ntype Context = {\n sdk: SendbirdChatSDK;\n currentUser?: SendbirdUser;\n setCurrentUser: React.Dispatch<React.SetStateAction<SendbirdUser | undefined>>;\n\n // helper functions\n updateCurrentUserInfo: (nickname: string, profile?: string | FileType) => Promise<SendbirdUser>;\n markAsDeliveredWithChannel: (channel: SendbirdGroupChannel) => void;\n\n features: {\n // UIKit features\n autoPushTokenRegistrationEnabled: boolean;\n channelListTypingIndicatorEnabled: boolean;\n channelListMessageReceiptStatusEnabled: boolean;\n\n // Sendbird application features\n deliveryReceiptEnabled: boolean;\n broadcastChannelEnabled: boolean;\n superGroupChannelEnabled: boolean;\n reactionEnabled: boolean;\n };\n};\n\nexport const SendbirdChatContext = React.createContext<Context | null>(null);\nexport const SendbirdChatProvider = ({\n children,\n sdkInstance,\n enableAutoPushTokenRegistration,\n enableChannelListMessageReceiptStatus,\n enableChannelListTypingIndicator,\n}: Props) => {\n const [currentUser, _setCurrentUser] = useState<SendbirdUser>();\n const forceUpdate = useForceUpdate();\n const appFeatures = useAppFeatures(sdkInstance);\n\n const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {\n // NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser\n _setCurrentUser(user);\n forceUpdate();\n }, []);\n\n const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(\n async (nickname, profile) => {\n let user = currentUser;\n\n if (!user) throw new Error('Current user is not defined, please connect using `useConnection()` hook first');\n\n if (typeof profile === 'undefined') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, sdkInstance.currentUser.profileUrl);\n } else if (typeof profile === 'string') {\n user = await sdkInstance.updateCurrentUserInfo(nickname, profile);\n } else if (typeof profile === 'object') {\n user = await sdkInstance.updateCurrentUserInfoWithProfileImage(nickname, profile);\n } else {\n throw new Error(`Cannot update profile, not supported profile type(${typeof profile})`);\n }\n\n setCurrentUser(user);\n return user;\n },\n [sdkInstance, currentUser, setCurrentUser],\n );\n\n const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(\n (channel: SendbirdGroupChannel) => {\n if (appFeatures.deliveryReceiptEnabled && channel.unreadMessageCount > 0) {\n sdkInstance.markAsDelivered(channel.url);\n }\n },\n [sdkInstance, appFeatures.deliveryReceiptEnabled],\n );\n\n useEffect(() => {\n const listener = (status: AppStateStatus) => {\n // 'active' | 'background' | 'inactive' | 'unknown' | 'extension';\n if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();\n else if (status === 'background') sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();\n };\n\n const subscriber = AppState.addEventListener('change', listener);\n return () => subscriber.remove();\n }, [sdkInstance]);\n\n const value: Context = {\n sdk: sdkInstance,\n currentUser,\n setCurrentUser,\n\n updateCurrentUserInfo,\n markAsDeliveredWithChannel,\n\n features: {\n ...appFeatures,\n autoPushTokenRegistrationEnabled: enableAutoPushTokenRegistration,\n channelListTypingIndicatorEnabled: enableChannelListTypingIndicator,\n channelListMessageReceiptStatusEnabled: enableChannelListMessageReceiptStatus,\n },\n };\n\n return <SendbirdChatContext.Provider value={value}>{children}</SendbirdChatContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,SAA7B,EAAwCC,QAAxC,QAAwD,OAAxD;AACA,SAASC,QAAT,QAAyC,cAAzC;AAEA,SAASC,cAAT,QAA+B,4BAA/B;AAEA,SAASC,cAAT,QAA+B,uBAA/B;AAmCA,OAAO,MAAMC,mBAAmB,gBAAGP,KAAK,CAACQ,aAAN,CAAoC,IAApC,CAA5B;AACP,OAAO,MAAMC,oBAAoB,GAAG,QAMvB;EAAA,IANwB;IACnCC,QADmC;IAEnCC,WAFmC;IAGnCC,+BAHmC;IAInCC,qCAJmC;IAKnCC;EALmC,CAMxB;EACX,MAAM,CAACC,WAAD,EAAcC,eAAd,IAAiCb,QAAQ,EAA/C;EACA,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ACoB,eAAZ,CAA4BH,OAAO,CAACI,GAApC;IACD;EACF,CALkF,EAMnF,CAACrB,WAAD,EAAcO,WAAW,CAACW,sBAA1B,CANmF,CAArF;EASA3B,SAAS,CAAC,MAAM;IACd,MAAM+B,QAAQ,GAAIC,MAAD,IAA4B;MAC3C;MACA,IAAIA,MAAM,KAAK,QAAf,EAAyBvB,WAAW,CAACwB,kBAAZ,OAAqC,QAArC,IAAiDxB,WAAW,CAACyB,kBAAZ,EAAjD,CAAzB,KACK,IAAIF,MAAM,KAAK,YAAf,EAA6BvB,WAAW,CAACwB,kBAAZ,OAAqC,MAArC,IAA+CxB,WAAW,CAAC0B,kBAAZ,EAA/C;IACnC,CAJD;;IAMA,MAAMC,UAAU,GAAGlC,QAAQ,CAACmC,gBAAT,CAA0B,QAA1B,EAAoCN,QAApC,CAAnB;IACA,OAAO,MAAMK,UAAU,CAACE,MAAX,EAAb;EACD,CATQ,EASN,CAAC7B,WAAD,CATM,CAAT;EAWA,MAAM8B,KAAc,GAAG;IACrBC,GAAG,EAAE/B,WADgB;IAErBI,WAFqB;IAGrBI,cAHqB;IAKrBE,qBALqB;IAMrBM,0BANqB;IAQrBgB,QAAQ,EAAE,EACR,GAAGzB,WADK;MAER0B,gCAAgC,EAAEhC,+BAF1B;MAGRiC,iCAAiC,EAAE/B,gCAH3B;MAIRgC,sCAAsC,EAAEjC;IAJhC;EARW,CAAvB;EAgBA,oBAAO,oBAAC,mBAAD,CAAqB,QAArB;IAA8B,KAAK,EAAE4B;EAArC,GAA6C/B,QAA7C,CAAP;AACD,CA5EM"}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '1.1.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '1.1.3';\nexport default VERSION;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,OAAhB;AACA,eAAeA,OAAf"}
|
|
@@ -5,7 +5,7 @@ import type { StringSet } from '../localization/StringSet.type';
|
|
|
5
5
|
import type { ClipboardServiceInterface, FileServiceInterface, MediaServiceInterface, NotificationServiceInterface } from '../platform/types';
|
|
6
6
|
import type { ErrorBoundaryProps, LocalCacheStorage } from '../types';
|
|
7
7
|
export declare const SendbirdUIKit: Readonly<{
|
|
8
|
-
VERSION: "1.1.
|
|
8
|
+
VERSION: "1.1.3";
|
|
9
9
|
PLATFORM: string;
|
|
10
10
|
}>;
|
|
11
11
|
export declare type SendbirdUIKitContainerProps = React.PropsWithChildren<{
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const VERSION = "1.1.
|
|
1
|
+
declare const VERSION = "1.1.3";
|
|
2
2
|
export default VERSION;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-react-native",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "react-native-uikit",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@sendbird/uikit-chat-hooks": "1.1.
|
|
45
|
-
"@sendbird/uikit-react-native-foundation": "1.1.
|
|
46
|
-
"@sendbird/uikit-utils": "1.1.
|
|
44
|
+
"@sendbird/uikit-chat-hooks": "1.1.3",
|
|
45
|
+
"@sendbird/uikit-react-native-foundation": "1.1.3",
|
|
46
|
+
"@sendbird/uikit-utils": "1.1.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@react-native-clipboard/clipboard": "^1.8.5",
|
|
@@ -159,5 +159,5 @@
|
|
|
159
159
|
"readmeFile": "./README.md",
|
|
160
160
|
"displayName": "@sendbird/uikit-react-native"
|
|
161
161
|
},
|
|
162
|
-
"gitHead": "
|
|
162
|
+
"gitHead": "99c133a8bbee3d806bf72ffc040acdd5c883d1d7"
|
|
163
163
|
}
|
|
@@ -91,7 +91,7 @@ export const SendbirdChatProvider = ({
|
|
|
91
91
|
const listener = (status: AppStateStatus) => {
|
|
92
92
|
// 'active' | 'background' | 'inactive' | 'unknown' | 'extension';
|
|
93
93
|
if (status === 'active') sdkInstance.getConnectionState() === 'CLOSED' && sdkInstance.setForegroundState();
|
|
94
|
-
else sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
94
|
+
else if (status === 'background') sdkInstance.getConnectionState() === 'OPEN' && sdkInstance.setBackgroundState();
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
const subscriber = AppState.addEventListener('change', listener);
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const VERSION = '1.1.
|
|
1
|
+
const VERSION = '1.1.3';
|
|
2
2
|
export default VERSION;
|