Skip to content

Commit

Permalink
fix(uikit): fixed to useContext type compiles the correct package path
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 committed Jan 26, 2023
1 parent 0e9c2c4 commit d17ccb0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ type Props = React.PropsWithChildren<{
mediaService: MediaServiceInterface;
}>;

export const PlatformServiceContext = React.createContext<Props | null>(null);
export type PlatformServiceContextType = {
fileService: FileServiceInterface;
clipboardService: ClipboardServiceInterface;
notificationService: NotificationServiceInterface;
mediaService: MediaServiceInterface;
};

export const PlatformServiceContext = React.createContext<PlatformServiceContextType | null>(null);
export const PlatformServiceProvider = ({
children,
fileService,
Expand Down
12 changes: 6 additions & 6 deletions packages/uikit-react-native/src/contexts/SendbirdChatCtx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface Props extends UIKitFeaturesInSendbirdChatContext, React.PropsWithChild
imageCompressionConfig: ImageCompressionConfig;
}

type Context = {
export type SendbirdChatContextType = {
sdk: SendbirdChatSDK;
emojiManager: EmojiManager;
mentionManager: MentionManager;
Expand Down Expand Up @@ -59,7 +59,7 @@ type Context = {
};
};

export const SendbirdChatContext = React.createContext<Context | null>(null);
export const SendbirdChatContext = React.createContext<SendbirdChatContextType | null>(null);
export const SendbirdChatProvider = ({
children,
sdkInstance,
Expand All @@ -77,13 +77,13 @@ export const SendbirdChatProvider = ({
const forceUpdate = useForceUpdate();
const appFeatures = useAppFeatures(sdkInstance);

const setCurrentUser: Context['setCurrentUser'] = useCallback((user) => {
const setCurrentUser: SendbirdChatContextType['setCurrentUser'] = useCallback((user) => {
// NOTE: Sendbird SDK handle User object is always same object, so force update after setCurrentUser
_setCurrentUser(user);
forceUpdate();
}, []);

const updateCurrentUserInfo: Context['updateCurrentUserInfo'] = useCallback(
const updateCurrentUserInfo: SendbirdChatContextType['updateCurrentUserInfo'] = useCallback(
async (nickname, profile) => {
let user = currentUser;

Expand Down Expand Up @@ -115,7 +115,7 @@ export const SendbirdChatProvider = ({
[sdkInstance, currentUser, setCurrentUser],
);

const markAsDeliveredWithChannel: Context['markAsDeliveredWithChannel'] = useCallback(
const markAsDeliveredWithChannel: SendbirdChatContextType['markAsDeliveredWithChannel'] = useCallback(
(channel: SendbirdGroupChannel) => {
if (appFeatures.deliveryReceiptEnabled) confirmAndMarkAsDelivered([channel]);
},
Expand All @@ -128,7 +128,7 @@ export const SendbirdChatProvider = ({
else if (status === 'background') sdkInstance.connectionState === 'OPEN' && sdkInstance.setBackgroundState();
});

const value: Context = {
const value: SendbirdChatContextType = {
sdk: sdkInstance,
emojiManager,
mentionManager,
Expand Down

0 comments on commit d17ccb0

Please sign in to comment.