Skip to content

Commit

Permalink
Merge pull request #206 from sendbird/chore/remove-allSettled
Browse files Browse the repository at this point in the history
chore: remove Promise.allSettled
  • Loading branch information
bang9 authored Oct 22, 2024
2 parents 7513d04 + 631077d commit c0e94a2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
onClose={onClose}
onDismiss={() => {
onDismiss();
Promise.allSettled([playerService.reset(), recorderService.reset()]);
playerService.reset().catch(() => {});
recorderService.reset().catch(() => {});
}}
backgroundStyle={{ justifyContent: 'flex-end' }}
visible={voiceMessageInputVisible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export const PlatformServiceProvider = ({ children, voiceMessageConfig, ...servi

useAppState('change', (state) => {
if (state !== 'active') {
Promise.allSettled([services.playerService.reset(), services.recorderService.reset()]);
services.playerService.reset().catch(() => {});
services.recorderService.reset().catch(() => {});
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ const createGroupChannelFragment = (initModule?: Partial<GroupChannelModule>): G
startingPoint: internalSearchItem?.startingPoint,
});

const onBlurFragment = () => {
return Promise.allSettled([playerService.reset(), recorderService.reset()]);
const onBlurFragment = async () => {
await playerService.reset().catch(() => {});
await recorderService.reset().catch(() => {});
};
const _onPressHeaderLeft = useFreshCallback(async () => {
voiceMessageStatusManager.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ const createGroupChannelThreadFragment = (
startingPoint,
});

const onBlurFragment = () => {
return Promise.allSettled([playerService.reset(), recorderService.reset()]);
const onBlurFragment = async () => {
await playerService.reset().catch(() => {});
await recorderService.reset().catch(() => {});
};
const _onPressHeaderLeft = useFreshCallback(async () => {
await onBlurFragment();
Expand Down
10 changes: 8 additions & 2 deletions packages/uikit-react-native/src/hooks/useConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ const useConnection = () => {
});
}

await Promise.allSettled([initEmoji(sdk, emojiManager), initDashboardConfigs(sdk)]);
await Promise.all([
initEmoji(sdk, emojiManager).catch(() => Logger.info('[useConnection]', 'initEmoji failure')),
initDashboardConfigs(sdk).catch(() => Logger.info('[useConnection]', 'initDashboardConfigs failure')),
]);

Logger.debug('[useConnection]', 'connected! (online)');
setCurrentUser(user);
Expand All @@ -67,7 +70,10 @@ const useConnection = () => {
Logger.warn('[useConnection]', 'clear cached-data');
await sdk.clearCachedData().catch((e) => Logger.warn('[useConnection]', 'clear cached-data failure', e));
} else if (sdk.currentUser) {
await Promise.allSettled([initEmoji(sdk, emojiManager), initDashboardConfigs(sdk)]);
await Promise.all([
initEmoji(sdk, emojiManager).catch(() => Logger.info('[useConnection]', 'initEmoji failure')),
initDashboardConfigs(sdk).catch(() => Logger.info('[useConnection]', 'initDashboardConfigs failure')),
]);

Logger.debug('[useConnection]', 'connected! (offline)');
setCurrentUser(sdk.currentUser);
Expand Down

0 comments on commit c0e94a2

Please sign in to comment.