Skip to content

Commit 297a768

Browse files
authored
feat: publish pubSub topics (#816)
* feat: export pubSub topics * fix: export SendbirdProvider and useSendbirdStateContext, not export default
1 parent 61d76b4 commit 297a768

File tree

4 files changed

+57
-24
lines changed

4 files changed

+57
-24
lines changed

rollup.module-exports.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export default {
2828
'handlers/UserEventHandler': 'src/lib/handlers/UserEventHandler.ts',
2929
'handlers/SessionHandler': 'src/lib/handlers/SessionHandler.ts',
3030

31+
// pubSub
32+
'pubSub/topics': 'src/lib/pubSub//topics.ts',
3133
// hooks
3234
'hooks/useModal': 'src/hooks/useModal/index.tsx',
3335
// utils

scripts/index.d.ts

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,24 @@ declare module "SendbirdUIKitGlobal" {
12581258
onThemeChange?(theme: string): void;
12591259
onEditProfile?(updatedUser: User): void;
12601260
}
1261+
1262+
/** UI */
1263+
export interface ModalProps {
1264+
className?: string;
1265+
hideFooter?: boolean;
1266+
disabled?: boolean;
1267+
type?: string;
1268+
isFullScreenOnMobile?: boolean;
1269+
isCloseOnClickOutside?: boolean;
1270+
children: React.ReactElement | string;
1271+
/**
1272+
* Do not use this! onCancel will be deprecated in v4. Use onClose instead.
1273+
*/
1274+
onCancel?: () => void;
1275+
onClose?: () => void;
1276+
onSubmit?: () => void;
1277+
renderHeader?: () => React.ReactElement;
1278+
}
12611279
}
12621280

12631281
declare module '@sendbird/uikit-react' {
@@ -1286,9 +1304,10 @@ declare module '@sendbird/uikit-react/App' {
12861304
}
12871305

12881306
declare module '@sendbird/uikit-react/SendbirdProvider' {
1289-
import type { SendbirdProviderProps } from 'SendbirdUIKitGlobal';
1290-
const SendbirdProvider: React.FunctionComponent<SendbirdProviderProps>;
1307+
import type { SendbirdProviderProps, SendBirdState } from 'SendbirdUIKitGlobal';
1308+
export const SendbirdProvider: React.FunctionComponent<SendbirdProviderProps>;
12911309
export default SendbirdProvider;
1310+
export function useSendbirdStateContext(): SendBirdState;
12921311
}
12931312

12941313
declare module '@sendbird/uikit-react/sendbirdSelectors' {
@@ -1299,7 +1318,7 @@ declare module '@sendbird/uikit-react/sendbirdSelectors' {
12991318

13001319
declare module '@sendbird/uikit-react/useSendbirdStateContext' {
13011320
import type { SendBirdState } from 'SendbirdUIKitGlobal';
1302-
function useSendbirdStateContext(): SendBirdState;
1321+
export function useSendbirdStateContext(): SendBirdState;
13031322
export default useSendbirdStateContext;
13041323
}
13051324

@@ -1334,11 +1353,36 @@ declare module '@sendbird/uikit-react/handlers/UserEventHandler' {
13341353
export default UserEventHandler;
13351354
}
13361355

1356+
/** pubSub */
1357+
declare module '@Sendbird/uikit-react/pubSub/topics' {
1358+
export enum PUBSUB_TOPICS {
1359+
// Group Channel
1360+
USER_UPDATED = 'USER_UPDATED',
1361+
SEND_MESSAGE_START = 'SEND_MESSAGE_START',
1362+
SEND_MESSAGE_FAILED = 'SEND_MESSAGE_FAILED',
1363+
SEND_USER_MESSAGE = 'SEND_USER_MESSAGE',
1364+
SEND_FILE_MESSAGE = 'SEND_FILE_MESSAGE',
1365+
ON_FILE_INFO_UPLOADED = 'ON_FILE_INFO_UPLOADED',
1366+
UPDATE_USER_MESSAGE = 'UPDATE_USER_MESSAGE',
1367+
DELETE_MESSAGE = 'DELETE_MESSAGE',
1368+
LEAVE_CHANNEL = 'LEAVE_CHANNEL',
1369+
CREATE_CHANNEL = 'CREATE_CHANNEL',
1370+
// Open Channel
1371+
UPDATE_OPEN_CHANNEL = 'UPDATE_OPEN_CHANNEL',
1372+
}
1373+
export enum PublishingModuleType {
1374+
CHANNEL = 'CHANNEL',
1375+
THREAD = 'THREAD',
1376+
}
1377+
export default PUBSUB_TOPICS;
1378+
}
1379+
13371380
/** hooks */
13381381
declare module '@sendbird/uikit-react/hooks/useModal' {
1382+
import type { ModalProps } from 'SendbirdUIKitGlobal';
13391383
export type OpenGlobalModalProps = {
13401384
modalProps: ModalProps;
1341-
childElement: (props: { closeModal: () => void }) => ReactElement;
1385+
childElement: (props: { closeModal: () => void }) => React.ReactElement;
13421386
};
13431387
export interface GlobalModalContextInterface {
13441388
openModal: (props: OpenGlobalModalProps) => void;
@@ -2568,22 +2612,7 @@ declare module '@sendbird/uikit-react/ui/MessageStatus' {
25682612
}
25692613

25702614
declare module '@sendbird/uikit-react/ui/Modal' {
2571-
interface ModalProps {
2572-
className?: string;
2573-
hideFooter?: boolean;
2574-
disabled?: boolean;
2575-
type?: string;
2576-
isFullScreenOnMobile?: boolean;
2577-
isCloseOnClickOutside?: boolean;
2578-
children: React.ReactElement | string;
2579-
/**
2580-
* Do not use this! onCancel will be deprecated in v4. Use onClose instead.
2581-
*/
2582-
onCancel?: () => void;
2583-
onClose?: () => void;
2584-
onSubmit?: () => void;
2585-
renderHeader?: () => React.ReactElement;
2586-
}
2615+
import type { ModalProps } from 'SendbirdUIKitGlobal';
25872616
const Modal: React.FC<ModalProps>;
25882617
export default Modal;
25892618
}

src/hooks/useSendbirdStateContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { SendBirdState } from '../lib/types';
1313

1414
const NO_CONTEXT_ERROR = 'No sendbird state value available. Make sure you are rendering `<SendbirdProvider>` at the top of your app.';
1515

16-
function useSendbirdStateContext(): SendBirdState {
16+
export function useSendbirdStateContext(): SendBirdState {
1717
const context = useContext(SendbirdSdkContext);
1818
if (!context) throw new Error(NO_CONTEXT_ERROR);
1919
return context;

src/lib/Sendbird.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import {
4848
} from './types';
4949
import { GlobalModalProvider } from '../hooks/useModal';
5050

51+
export { useSendbirdStateContext } from '../hooks/useSendbirdStateContext';
52+
5153
export type UserListQueryType = {
5254
hasNext?: boolean;
5355
next: () => Promise<Array<User>>;
@@ -106,7 +108,7 @@ export interface SendbirdProviderProps extends CommonUIKitConfigProps, React.Pro
106108
eventHandlers?: SBUEventHandlers;
107109
}
108110

109-
function Sendbird(props: SendbirdProviderProps) {
111+
export function SendbirdProvider(props: SendbirdProviderProps) {
110112
const localConfigs = uikitConfigMapper({
111113
legacyConfig: {
112114
replyType: props.replyType,
@@ -320,7 +322,7 @@ const SendbirdSDK = ({
320322
accessToken,
321323
theme: currentTheme,
322324
setCurrentTheme,
323-
setCurrenttheme: setCurrentTheme,
325+
setCurrenttheme: setCurrentTheme, // deprecated: typo
324326
isMultipleFilesMessageEnabled,
325327
uikitUploadSizeLimit,
326328
uikitMultipleFilesMessageLimit,
@@ -388,4 +390,4 @@ const SendbirdSDK = ({
388390
);
389391
};
390392

391-
export default Sendbird;
393+
export default SendbirdProvider;

0 commit comments

Comments
 (0)