@selfcommunity/react-core 0.4.0-alpha.11 → 0.4.0-alpha.110
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/cjs/components/provider/SCAlertMessagesProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js +2 -25
- package/lib/cjs/components/provider/SCContextProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCContextProvider/index.js +3 -29
- package/lib/cjs/components/provider/SCLocaleProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCLocaleProvider/index.js +2 -25
- package/lib/cjs/components/provider/SCNotificationProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCNotificationProvider/index.js +7 -31
- package/lib/cjs/components/provider/SCPreferencesProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js +2 -25
- package/lib/cjs/components/provider/SCRoutingProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCRoutingProvider/index.js +4 -27
- package/lib/cjs/components/provider/SCThemeProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCThemeProvider/index.js +6 -32
- package/lib/cjs/components/provider/SCUserProvider/index.d.ts +0 -1
- package/lib/cjs/components/provider/SCUserProvider/index.js +32 -49
- package/lib/cjs/components/provider/SCVoteProvider/index.d.ts +37 -0
- package/lib/cjs/components/provider/SCVoteProvider/index.js +112 -0
- package/lib/cjs/components/router/index.d.ts +0 -1
- package/lib/cjs/components/router/index.js +5 -39
- package/lib/cjs/constants/Actions.d.ts +0 -1
- package/lib/cjs/constants/Actions.js +0 -1
- package/lib/cjs/constants/Cache.d.ts +23 -15
- package/lib/cjs/constants/Cache.js +28 -17
- package/lib/cjs/constants/ContextProviders.d.ts +0 -1
- package/lib/cjs/constants/ContextProviders.js +12 -13
- package/lib/cjs/constants/Device.d.ts +22 -1
- package/lib/cjs/constants/Device.js +27 -2
- package/lib/cjs/constants/Errors.d.ts +0 -1
- package/lib/cjs/constants/Errors.js +0 -1
- package/lib/cjs/constants/Features.d.ts +0 -43
- package/lib/cjs/constants/Features.js +1 -44
- package/lib/cjs/constants/Locale.d.ts +0 -1
- package/lib/cjs/constants/Locale.js +0 -1
- package/lib/cjs/constants/Notification.d.ts +0 -1
- package/lib/cjs/constants/Notification.js +0 -1
- package/lib/cjs/constants/Notifications.d.ts +3 -1
- package/lib/cjs/constants/Notifications.js +7 -2
- package/lib/cjs/constants/Preferences.d.ts +13 -2
- package/lib/cjs/constants/Preferences.js +21 -5
- package/lib/cjs/constants/Routes.d.ts +3 -1
- package/lib/cjs/constants/Routes.js +8 -3
- package/lib/cjs/constants/Session.d.ts +0 -1
- package/lib/cjs/constants/Session.js +0 -1
- package/lib/cjs/constants/Theme.d.ts +0 -1
- package/lib/cjs/constants/Theme.js +0 -1
- package/lib/cjs/constants/Vote.d.ts +6 -0
- package/lib/cjs/constants/Vote.js +9 -0
- package/lib/cjs/constants/WebSocket.d.ts +0 -1
- package/lib/cjs/constants/WebSocket.js +0 -1
- package/lib/cjs/hooks/useSCAuth.d.ts +0 -1
- package/lib/cjs/hooks/useSCAuth.js +34 -51
- package/lib/cjs/hooks/useSCBlockedUsersManager.d.ts +30 -0
- package/lib/cjs/hooks/useSCBlockedUsersManager.js +108 -0
- package/lib/cjs/hooks/useSCCachingManager.d.ts +5 -5
- package/lib/cjs/hooks/useSCCachingManager.js +21 -6
- package/lib/cjs/hooks/useSCConnectionsManager.d.ts +8 -5
- package/lib/cjs/hooks/useSCConnectionsManager.js +141 -91
- package/lib/cjs/hooks/useSCFetchAddressingTagList.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchAddressingTagList.js +2 -26
- package/lib/cjs/hooks/useSCFetchBroadcastMessages.d.ts +30 -0
- package/lib/cjs/hooks/useSCFetchBroadcastMessages.js +91 -0
- package/lib/cjs/hooks/useSCFetchCategories.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchCategories.js +2 -11
- package/lib/cjs/hooks/useSCFetchCategory.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchCategory.js +13 -12
- package/lib/cjs/hooks/useSCFetchCommentObject.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObject.js +1 -2
- package/lib/cjs/hooks/useSCFetchCommentObjects.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObjects.js +2 -5
- package/lib/cjs/hooks/useSCFetchContributors.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchContributors.js +2 -5
- package/lib/cjs/hooks/useSCFetchCustomAdv.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchCustomAdv.js +2 -5
- package/lib/cjs/hooks/useSCFetchFeed.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchFeed.js +3 -6
- package/lib/cjs/hooks/useSCFetchFeedObject.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchFeedObject.js +0 -1
- package/lib/cjs/hooks/useSCFetchIncubator.d.ts +4 -2
- package/lib/cjs/hooks/useSCFetchIncubator.js +28 -8
- package/lib/cjs/hooks/useSCFetchPrivateMessageSnippets.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchPrivateMessageSnippets.js +16 -26
- package/lib/cjs/hooks/useSCFetchReactions.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchReactions.js +3 -50
- package/lib/cjs/hooks/useSCFetchTag.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchTag.js +0 -1
- package/lib/cjs/hooks/useSCFetchUser.d.ts +2 -1
- package/lib/cjs/hooks/useSCFetchUser.js +33 -8
- package/lib/cjs/hooks/useSCFetchUserBlockedBy.d.ts +17 -0
- package/lib/cjs/hooks/useSCFetchUserBlockedBy.js +83 -0
- package/lib/cjs/hooks/useSCFetchUserProviders.d.ts +0 -1
- package/lib/cjs/hooks/useSCFetchUserProviders.js +0 -1
- package/lib/cjs/hooks/useSCFetchVote.d.ts +2 -3
- package/lib/cjs/hooks/useSCFetchVote.js +58 -73
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.d.ts +4 -5
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js +26 -17
- package/lib/cjs/hooks/useSCFollowedManager.d.ts +4 -5
- package/lib/cjs/hooks/useSCFollowedManager.js +38 -24
- package/lib/cjs/hooks/useSCFollowersManager.d.ts +4 -5
- package/lib/cjs/hooks/useSCFollowersManager.js +7 -10
- package/lib/cjs/hooks/useSCMediaClick.d.ts +0 -1
- package/lib/cjs/hooks/useSCMediaClick.js +0 -1
- package/lib/cjs/hooks/useSCMobileNativePushMessaging.d.ts +19 -0
- package/lib/cjs/hooks/useSCMobileNativePushMessaging.js +143 -0
- package/lib/cjs/hooks/useSCSettingsManager.d.ts +0 -1
- package/lib/cjs/hooks/useSCSettingsManager.js +0 -1
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.d.ts +12 -3
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js +39 -32
- package/lib/cjs/hooks/useSCUserIsBlocked.d.ts +18 -0
- package/lib/cjs/hooks/useSCUserIsBlocked.js +33 -0
- package/lib/cjs/hooks/useSCWebPushMessaging.d.ts +12 -2
- package/lib/cjs/hooks/useSCWebPushMessaging.js +188 -106
- package/lib/cjs/hooks/useSCWebSocket.d.ts +1 -2
- package/lib/cjs/hooks/useSCWebSocket.js +3 -6
- package/lib/cjs/index.d.ts +4 -2
- package/lib/cjs/index.js +41 -61
- package/lib/cjs/themes/theme.d.ts +0 -1
- package/lib/cjs/themes/theme.js +4 -80
- package/lib/cjs/types/context.d.ts +96 -6
- package/lib/cjs/types/context.js +0 -1
- package/lib/cjs/types/index.d.ts +2 -3
- package/lib/cjs/types/index.js +0 -1
- package/lib/cjs/types/theme.d.ts +1 -2
- package/lib/cjs/types/theme.js +0 -1
- package/lib/cjs/utils/errors.d.ts +5 -6
- package/lib/cjs/utils/errors.js +13 -34
- package/lib/cjs/utils/hooks/index.d.ts +0 -1
- package/lib/cjs/utils/hooks/index.js +6 -9
- package/lib/cjs/utils/hooks/useEffectOnce.d.ts +0 -1
- package/lib/cjs/utils/hooks/useEffectOnce.js +0 -1
- package/lib/cjs/utils/hooks/useIsComponentMountedRef.d.ts +0 -1
- package/lib/cjs/utils/hooks/useIsComponentMountedRef.js +0 -1
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.d.ts +0 -1
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.js +0 -1
- package/lib/cjs/utils/hooks/useNoInitialEffect.d.ts +0 -1
- package/lib/cjs/utils/hooks/useNoInitialEffect.js +0 -1
- package/lib/cjs/utils/hooks/usePreviousValue.d.ts +0 -1
- package/lib/cjs/utils/hooks/usePreviousValue.js +0 -1
- package/lib/cjs/utils/locale.d.ts +0 -1
- package/lib/cjs/utils/locale.js +2 -5
- package/lib/cjs/utils/notification.d.ts +8 -0
- package/lib/cjs/utils/notification.js +20 -0
- package/lib/cjs/utils/pagination.d.ts +0 -1
- package/lib/cjs/utils/pagination.js +0 -1
- package/lib/cjs/utils/user.d.ts +0 -1
- package/lib/cjs/utils/user.js +0 -1
- package/lib/cjs/utils/validator.d.ts +49 -3
- package/lib/cjs/utils/validator.js +144 -41
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js +0 -1
- package/lib/esm/components/provider/SCContextProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCContextProvider/index.js +0 -1
- package/lib/esm/components/provider/SCLocaleProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCLocaleProvider/index.js +0 -1
- package/lib/esm/components/provider/SCNotificationProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCNotificationProvider/index.js +3 -2
- package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCPreferencesProvider/index.js +0 -1
- package/lib/esm/components/provider/SCRoutingProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCRoutingProvider/index.js +1 -2
- package/lib/esm/components/provider/SCThemeProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCThemeProvider/index.js +1 -2
- package/lib/esm/components/provider/SCUserProvider/index.d.ts +0 -1
- package/lib/esm/components/provider/SCUserProvider/index.js +22 -14
- package/lib/esm/components/provider/SCVoteProvider/index.d.ts +37 -0
- package/lib/esm/components/provider/SCVoteProvider/index.js +106 -0
- package/lib/esm/components/router/index.d.ts +0 -1
- package/lib/esm/components/router/index.js +2 -13
- package/lib/esm/constants/Actions.d.ts +0 -1
- package/lib/esm/constants/Actions.js +0 -1
- package/lib/esm/constants/Cache.d.ts +23 -15
- package/lib/esm/constants/Cache.js +23 -15
- package/lib/esm/constants/ContextProviders.d.ts +0 -1
- package/lib/esm/constants/ContextProviders.js +4 -3
- package/lib/esm/constants/Device.d.ts +22 -1
- package/lib/esm/constants/Device.js +26 -1
- package/lib/esm/constants/Errors.d.ts +0 -1
- package/lib/esm/constants/Errors.js +0 -1
- package/lib/esm/constants/Features.d.ts +0 -43
- package/lib/esm/constants/Features.js +0 -43
- package/lib/esm/constants/Locale.d.ts +0 -1
- package/lib/esm/constants/Locale.js +0 -1
- package/lib/esm/constants/Notification.d.ts +0 -1
- package/lib/esm/constants/Notification.js +0 -1
- package/lib/esm/constants/Notifications.d.ts +3 -1
- package/lib/esm/constants/Notifications.js +6 -1
- package/lib/esm/constants/Preferences.d.ts +13 -2
- package/lib/esm/constants/Preferences.js +18 -3
- package/lib/esm/constants/Routes.d.ts +3 -1
- package/lib/esm/constants/Routes.js +7 -2
- package/lib/esm/constants/Session.d.ts +0 -1
- package/lib/esm/constants/Session.js +0 -1
- package/lib/esm/constants/Theme.d.ts +0 -1
- package/lib/esm/constants/Theme.js +0 -1
- package/lib/esm/constants/Vote.d.ts +6 -0
- package/lib/esm/constants/Vote.js +6 -0
- package/lib/esm/constants/WebSocket.d.ts +0 -1
- package/lib/esm/constants/WebSocket.js +0 -1
- package/lib/esm/hooks/useSCAuth.d.ts +0 -1
- package/lib/esm/hooks/useSCAuth.js +31 -22
- package/lib/esm/hooks/useSCBlockedUsersManager.d.ts +30 -0
- package/lib/esm/hooks/useSCBlockedUsersManager.js +105 -0
- package/lib/esm/hooks/useSCCachingManager.d.ts +5 -5
- package/lib/esm/hooks/useSCCachingManager.js +21 -6
- package/lib/esm/hooks/useSCConnectionsManager.d.ts +8 -5
- package/lib/esm/hooks/useSCConnectionsManager.js +138 -86
- package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchAddressingTagList.js +3 -4
- package/lib/esm/hooks/useSCFetchBroadcastMessages.d.ts +30 -0
- package/lib/esm/hooks/useSCFetchBroadcastMessages.js +89 -0
- package/lib/esm/hooks/useSCFetchCategories.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchCategories.js +1 -10
- package/lib/esm/hooks/useSCFetchCategory.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchCategory.js +15 -14
- package/lib/esm/hooks/useSCFetchCommentObject.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchCommentObject.js +1 -2
- package/lib/esm/hooks/useSCFetchCommentObjects.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchCommentObjects.js +0 -1
- package/lib/esm/hooks/useSCFetchContributors.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchContributors.js +0 -1
- package/lib/esm/hooks/useSCFetchCustomAdv.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchCustomAdv.js +0 -1
- package/lib/esm/hooks/useSCFetchFeed.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchFeed.js +1 -2
- package/lib/esm/hooks/useSCFetchFeedObject.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchFeedObject.js +0 -1
- package/lib/esm/hooks/useSCFetchIncubator.d.ts +4 -2
- package/lib/esm/hooks/useSCFetchIncubator.js +29 -9
- package/lib/esm/hooks/useSCFetchPrivateMessageSnippets.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchPrivateMessageSnippets.js +15 -25
- package/lib/esm/hooks/useSCFetchReactions.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchReactions.js +5 -29
- package/lib/esm/hooks/useSCFetchTag.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchTag.js +0 -1
- package/lib/esm/hooks/useSCFetchUser.d.ts +2 -1
- package/lib/esm/hooks/useSCFetchUser.js +34 -9
- package/lib/esm/hooks/useSCFetchUserBlockedBy.d.ts +17 -0
- package/lib/esm/hooks/useSCFetchUserBlockedBy.js +80 -0
- package/lib/esm/hooks/useSCFetchUserProviders.d.ts +0 -1
- package/lib/esm/hooks/useSCFetchUserProviders.js +0 -1
- package/lib/esm/hooks/useSCFetchVote.d.ts +2 -3
- package/lib/esm/hooks/useSCFetchVote.js +56 -69
- package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts +4 -5
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js +25 -14
- package/lib/esm/hooks/useSCFollowedManager.d.ts +4 -5
- package/lib/esm/hooks/useSCFollowedManager.js +37 -21
- package/lib/esm/hooks/useSCFollowersManager.d.ts +4 -5
- package/lib/esm/hooks/useSCFollowersManager.js +4 -5
- package/lib/esm/hooks/useSCMediaClick.d.ts +0 -1
- package/lib/esm/hooks/useSCMediaClick.js +0 -1
- package/lib/esm/hooks/useSCMobileNativePushMessaging.d.ts +19 -0
- package/lib/esm/hooks/useSCMobileNativePushMessaging.js +140 -0
- package/lib/esm/hooks/useSCSettingsManager.d.ts +0 -1
- package/lib/esm/hooks/useSCSettingsManager.js +0 -1
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts +12 -3
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js +38 -29
- package/lib/esm/hooks/useSCUserIsBlocked.d.ts +18 -0
- package/lib/esm/hooks/useSCUserIsBlocked.js +29 -0
- package/lib/esm/hooks/useSCWebPushMessaging.d.ts +12 -2
- package/lib/esm/hooks/useSCWebPushMessaging.js +185 -82
- package/lib/esm/hooks/useSCWebSocket.d.ts +1 -2
- package/lib/esm/hooks/useSCWebSocket.js +1 -2
- package/lib/esm/index.d.ts +4 -2
- package/lib/esm/index.js +4 -2
- package/lib/esm/themes/theme.d.ts +0 -1
- package/lib/esm/themes/theme.js +1 -75
- package/lib/esm/types/context.d.ts +96 -6
- package/lib/esm/types/context.js +0 -1
- package/lib/esm/types/index.d.ts +2 -3
- package/lib/esm/types/index.js +0 -1
- package/lib/esm/types/theme.d.ts +1 -2
- package/lib/esm/types/theme.js +0 -1
- package/lib/esm/utils/errors.d.ts +5 -6
- package/lib/esm/utils/errors.js +10 -8
- package/lib/esm/utils/hooks/index.d.ts +0 -1
- package/lib/esm/utils/hooks/index.js +0 -1
- package/lib/esm/utils/hooks/useEffectOnce.d.ts +0 -1
- package/lib/esm/utils/hooks/useEffectOnce.js +0 -1
- package/lib/esm/utils/hooks/useIsComponentMountedRef.d.ts +0 -1
- package/lib/esm/utils/hooks/useIsComponentMountedRef.js +0 -1
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.d.ts +0 -1
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.js +0 -1
- package/lib/esm/utils/hooks/useNoInitialEffect.d.ts +0 -1
- package/lib/esm/utils/hooks/useNoInitialEffect.js +0 -1
- package/lib/esm/utils/hooks/usePreviousValue.d.ts +0 -1
- package/lib/esm/utils/hooks/usePreviousValue.js +0 -1
- package/lib/esm/utils/locale.d.ts +0 -1
- package/lib/esm/utils/locale.js +0 -1
- package/lib/esm/utils/notification.d.ts +8 -0
- package/lib/esm/utils/notification.js +15 -0
- package/lib/esm/utils/pagination.d.ts +0 -1
- package/lib/esm/utils/pagination.js +0 -1
- package/lib/esm/utils/user.d.ts +0 -1
- package/lib/esm/utils/user.js +0 -1
- package/lib/esm/utils/validator.d.ts +49 -3
- package/lib/esm/utils/validator.js +129 -8
- package/lib/umd/251.js +2 -0
- package/lib/umd/251.js.LICENSE.txt +1 -0
- package/lib/umd/react-core.js +1 -1
- package/lib/umd/react-core.js.LICENSE.txt +1 -1
- package/package.json +25 -24
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCAlertMessagesProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCContextProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCContextProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCLocaleProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCLocaleProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCNotificationProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCNotificationProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCPreferencesProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCPreferencesProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCRoutingProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCRoutingProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCThemeProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCThemeProvider/index.js.map +0 -1
- package/lib/cjs/components/provider/SCUserProvider/index.d.ts.map +0 -1
- package/lib/cjs/components/provider/SCUserProvider/index.js.map +0 -1
- package/lib/cjs/components/router/index.d.ts.map +0 -1
- package/lib/cjs/components/router/index.js.map +0 -1
- package/lib/cjs/constants/Actions.d.ts.map +0 -1
- package/lib/cjs/constants/Actions.js.map +0 -1
- package/lib/cjs/constants/Cache.d.ts.map +0 -1
- package/lib/cjs/constants/Cache.js.map +0 -1
- package/lib/cjs/constants/ContextProviders.d.ts.map +0 -1
- package/lib/cjs/constants/ContextProviders.js.map +0 -1
- package/lib/cjs/constants/Device.d.ts.map +0 -1
- package/lib/cjs/constants/Device.js.map +0 -1
- package/lib/cjs/constants/Errors.d.ts.map +0 -1
- package/lib/cjs/constants/Errors.js.map +0 -1
- package/lib/cjs/constants/Features.d.ts.map +0 -1
- package/lib/cjs/constants/Features.js.map +0 -1
- package/lib/cjs/constants/Locale.d.ts.map +0 -1
- package/lib/cjs/constants/Locale.js.map +0 -1
- package/lib/cjs/constants/Notification.d.ts.map +0 -1
- package/lib/cjs/constants/Notification.js.map +0 -1
- package/lib/cjs/constants/Notifications.d.ts.map +0 -1
- package/lib/cjs/constants/Notifications.js.map +0 -1
- package/lib/cjs/constants/Preferences.d.ts.map +0 -1
- package/lib/cjs/constants/Preferences.js.map +0 -1
- package/lib/cjs/constants/Routes.d.ts.map +0 -1
- package/lib/cjs/constants/Routes.js.map +0 -1
- package/lib/cjs/constants/Session.d.ts.map +0 -1
- package/lib/cjs/constants/Session.js.map +0 -1
- package/lib/cjs/constants/Theme.d.ts.map +0 -1
- package/lib/cjs/constants/Theme.js.map +0 -1
- package/lib/cjs/constants/WebSocket.d.ts.map +0 -1
- package/lib/cjs/constants/WebSocket.js.map +0 -1
- package/lib/cjs/hooks/useSCAuth.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCAuth.js.map +0 -1
- package/lib/cjs/hooks/useSCCachingManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCCachingManager.js.map +0 -1
- package/lib/cjs/hooks/useSCConnectionsManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCConnectionsManager.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchAddressingTagList.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchAddressingTagList.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchCategories.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchCategories.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchCategory.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchCategory.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObject.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObject.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObjects.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchCommentObjects.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchContributors.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchContributors.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchCustomAdv.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchCustomAdv.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchFeed.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchFeed.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchFeedObject.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchFeedObject.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchIncubator.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchIncubator.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchPrivateMessageSnippets.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchPrivateMessageSnippets.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchReactions.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchReactions.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchTag.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchTag.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchUser.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchUser.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchUserProviders.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchUserProviders.js.map +0 -1
- package/lib/cjs/hooks/useSCFetchVote.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFetchVote.js.map +0 -1
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFollowedCategoriesManager.js.map +0 -1
- package/lib/cjs/hooks/useSCFollowedManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFollowedManager.js.map +0 -1
- package/lib/cjs/hooks/useSCFollowersManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCFollowersManager.js.map +0 -1
- package/lib/cjs/hooks/useSCMediaClick.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCMediaClick.js.map +0 -1
- package/lib/cjs/hooks/useSCSettingsManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCSettingsManager.js.map +0 -1
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCSubscribedIncubatorsManager.js.map +0 -1
- package/lib/cjs/hooks/useSCWebPushMessaging.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCWebPushMessaging.js.map +0 -1
- package/lib/cjs/hooks/useSCWebSocket.d.ts.map +0 -1
- package/lib/cjs/hooks/useSCWebSocket.js.map +0 -1
- package/lib/cjs/index.d.ts.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/themes/theme.d.ts.map +0 -1
- package/lib/cjs/themes/theme.js.map +0 -1
- package/lib/cjs/types/context.d.ts.map +0 -1
- package/lib/cjs/types/context.js.map +0 -1
- package/lib/cjs/types/index.d.ts.map +0 -1
- package/lib/cjs/types/index.js.map +0 -1
- package/lib/cjs/types/theme.d.ts.map +0 -1
- package/lib/cjs/types/theme.js.map +0 -1
- package/lib/cjs/utils/errors.d.ts.map +0 -1
- package/lib/cjs/utils/errors.js.map +0 -1
- package/lib/cjs/utils/hooks/index.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/index.js.map +0 -1
- package/lib/cjs/utils/hooks/useEffectOnce.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/useEffectOnce.js.map +0 -1
- package/lib/cjs/utils/hooks/useIsComponentMountedRef.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/useIsComponentMountedRef.js.map +0 -1
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/useIsomorphicLayoutEffect.js.map +0 -1
- package/lib/cjs/utils/hooks/useNoInitialEffect.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/useNoInitialEffect.js.map +0 -1
- package/lib/cjs/utils/hooks/usePreviousValue.d.ts.map +0 -1
- package/lib/cjs/utils/hooks/usePreviousValue.js.map +0 -1
- package/lib/cjs/utils/locale.d.ts.map +0 -1
- package/lib/cjs/utils/locale.js.map +0 -1
- package/lib/cjs/utils/pagination.d.ts.map +0 -1
- package/lib/cjs/utils/pagination.js.map +0 -1
- package/lib/cjs/utils/user.d.ts.map +0 -1
- package/lib/cjs/utils/user.js.map +0 -1
- package/lib/cjs/utils/validator.d.ts.map +0 -1
- package/lib/cjs/utils/validator.js.map +0 -1
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCAlertMessagesProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCContextProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCContextProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCLocaleProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCLocaleProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCNotificationProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCNotificationProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCPreferencesProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCPreferencesProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCRoutingProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCRoutingProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCThemeProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCThemeProvider/index.js.map +0 -1
- package/lib/esm/components/provider/SCUserProvider/index.d.ts.map +0 -1
- package/lib/esm/components/provider/SCUserProvider/index.js.map +0 -1
- package/lib/esm/components/router/index.d.ts.map +0 -1
- package/lib/esm/components/router/index.js.map +0 -1
- package/lib/esm/constants/Actions.d.ts.map +0 -1
- package/lib/esm/constants/Actions.js.map +0 -1
- package/lib/esm/constants/Cache.d.ts.map +0 -1
- package/lib/esm/constants/Cache.js.map +0 -1
- package/lib/esm/constants/ContextProviders.d.ts.map +0 -1
- package/lib/esm/constants/ContextProviders.js.map +0 -1
- package/lib/esm/constants/Device.d.ts.map +0 -1
- package/lib/esm/constants/Device.js.map +0 -1
- package/lib/esm/constants/Errors.d.ts.map +0 -1
- package/lib/esm/constants/Errors.js.map +0 -1
- package/lib/esm/constants/Features.d.ts.map +0 -1
- package/lib/esm/constants/Features.js.map +0 -1
- package/lib/esm/constants/Locale.d.ts.map +0 -1
- package/lib/esm/constants/Locale.js.map +0 -1
- package/lib/esm/constants/Notification.d.ts.map +0 -1
- package/lib/esm/constants/Notification.js.map +0 -1
- package/lib/esm/constants/Notifications.d.ts.map +0 -1
- package/lib/esm/constants/Notifications.js.map +0 -1
- package/lib/esm/constants/Preferences.d.ts.map +0 -1
- package/lib/esm/constants/Preferences.js.map +0 -1
- package/lib/esm/constants/Routes.d.ts.map +0 -1
- package/lib/esm/constants/Routes.js.map +0 -1
- package/lib/esm/constants/Session.d.ts.map +0 -1
- package/lib/esm/constants/Session.js.map +0 -1
- package/lib/esm/constants/Theme.d.ts.map +0 -1
- package/lib/esm/constants/Theme.js.map +0 -1
- package/lib/esm/constants/WebSocket.d.ts.map +0 -1
- package/lib/esm/constants/WebSocket.js.map +0 -1
- package/lib/esm/hooks/useSCAuth.d.ts.map +0 -1
- package/lib/esm/hooks/useSCAuth.js.map +0 -1
- package/lib/esm/hooks/useSCCachingManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCCachingManager.js.map +0 -1
- package/lib/esm/hooks/useSCConnectionsManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCConnectionsManager.js.map +0 -1
- package/lib/esm/hooks/useSCFetchAddressingTagList.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchAddressingTagList.js.map +0 -1
- package/lib/esm/hooks/useSCFetchCategories.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchCategories.js.map +0 -1
- package/lib/esm/hooks/useSCFetchCategory.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchCategory.js.map +0 -1
- package/lib/esm/hooks/useSCFetchCommentObject.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchCommentObject.js.map +0 -1
- package/lib/esm/hooks/useSCFetchCommentObjects.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchCommentObjects.js.map +0 -1
- package/lib/esm/hooks/useSCFetchContributors.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchContributors.js.map +0 -1
- package/lib/esm/hooks/useSCFetchCustomAdv.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchCustomAdv.js.map +0 -1
- package/lib/esm/hooks/useSCFetchFeed.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchFeed.js.map +0 -1
- package/lib/esm/hooks/useSCFetchFeedObject.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchFeedObject.js.map +0 -1
- package/lib/esm/hooks/useSCFetchIncubator.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchIncubator.js.map +0 -1
- package/lib/esm/hooks/useSCFetchPrivateMessageSnippets.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchPrivateMessageSnippets.js.map +0 -1
- package/lib/esm/hooks/useSCFetchReactions.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchReactions.js.map +0 -1
- package/lib/esm/hooks/useSCFetchTag.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchTag.js.map +0 -1
- package/lib/esm/hooks/useSCFetchUser.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchUser.js.map +0 -1
- package/lib/esm/hooks/useSCFetchUserProviders.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchUserProviders.js.map +0 -1
- package/lib/esm/hooks/useSCFetchVote.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFetchVote.js.map +0 -1
- package/lib/esm/hooks/useSCFollowedCategoriesManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFollowedCategoriesManager.js.map +0 -1
- package/lib/esm/hooks/useSCFollowedManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFollowedManager.js.map +0 -1
- package/lib/esm/hooks/useSCFollowersManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCFollowersManager.js.map +0 -1
- package/lib/esm/hooks/useSCMediaClick.d.ts.map +0 -1
- package/lib/esm/hooks/useSCMediaClick.js.map +0 -1
- package/lib/esm/hooks/useSCSettingsManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCSettingsManager.js.map +0 -1
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.d.ts.map +0 -1
- package/lib/esm/hooks/useSCSubscribedIncubatorsManager.js.map +0 -1
- package/lib/esm/hooks/useSCWebPushMessaging.d.ts.map +0 -1
- package/lib/esm/hooks/useSCWebPushMessaging.js.map +0 -1
- package/lib/esm/hooks/useSCWebSocket.d.ts.map +0 -1
- package/lib/esm/hooks/useSCWebSocket.js.map +0 -1
- package/lib/esm/index.d.ts.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/themes/theme.d.ts.map +0 -1
- package/lib/esm/themes/theme.js.map +0 -1
- package/lib/esm/types/context.d.ts.map +0 -1
- package/lib/esm/types/context.js.map +0 -1
- package/lib/esm/types/index.d.ts.map +0 -1
- package/lib/esm/types/index.js.map +0 -1
- package/lib/esm/types/theme.d.ts.map +0 -1
- package/lib/esm/types/theme.js.map +0 -1
- package/lib/esm/utils/errors.d.ts.map +0 -1
- package/lib/esm/utils/errors.js.map +0 -1
- package/lib/esm/utils/hooks/index.d.ts.map +0 -1
- package/lib/esm/utils/hooks/index.js.map +0 -1
- package/lib/esm/utils/hooks/useEffectOnce.d.ts.map +0 -1
- package/lib/esm/utils/hooks/useEffectOnce.js.map +0 -1
- package/lib/esm/utils/hooks/useIsComponentMountedRef.d.ts.map +0 -1
- package/lib/esm/utils/hooks/useIsComponentMountedRef.js.map +0 -1
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/lib/esm/utils/hooks/useIsomorphicLayoutEffect.js.map +0 -1
- package/lib/esm/utils/hooks/useNoInitialEffect.d.ts.map +0 -1
- package/lib/esm/utils/hooks/useNoInitialEffect.js.map +0 -1
- package/lib/esm/utils/hooks/usePreviousValue.d.ts.map +0 -1
- package/lib/esm/utils/hooks/usePreviousValue.js.map +0 -1
- package/lib/esm/utils/locale.d.ts.map +0 -1
- package/lib/esm/utils/locale.js.map +0 -1
- package/lib/esm/utils/pagination.d.ts.map +0 -1
- package/lib/esm/utils/pagination.js.map +0 -1
- package/lib/esm/utils/user.d.ts.map +0 -1
- package/lib/esm/utils/user.js.map +0 -1
- package/lib/esm/utils/validator.d.ts.map +0 -1
- package/lib/esm/utils/validator.js.map +0 -1
|
@@ -15,8 +15,18 @@ import { SCIncubatorType, SCUserType } from '@selfcommunity/types';
|
|
|
15
15
|
*/
|
|
16
16
|
export default function useSCSubscribedIncubatorsManager(user?: SCUserType): {
|
|
17
17
|
incubators: any[];
|
|
18
|
-
loading:
|
|
19
|
-
isLoading: (
|
|
18
|
+
loading: any[];
|
|
19
|
+
isLoading: (v: number | {
|
|
20
|
+
id: number;
|
|
21
|
+
}) => boolean;
|
|
22
|
+
subscribe?: undefined;
|
|
23
|
+
isSubscribed?: undefined;
|
|
24
|
+
refresh?: undefined;
|
|
25
|
+
emptyCache?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
incubators: any[];
|
|
28
|
+
loading: any[];
|
|
29
|
+
isLoading: (v: number | {
|
|
20
30
|
id: number;
|
|
21
31
|
}) => boolean;
|
|
22
32
|
subscribe: (incubator: SCIncubatorType) => Promise<any>;
|
|
@@ -24,4 +34,3 @@ export default function useSCSubscribedIncubatorsManager(user?: SCUserType): {
|
|
|
24
34
|
refresh: () => void;
|
|
25
35
|
emptyCache: () => void;
|
|
26
36
|
};
|
|
27
|
-
//# sourceMappingURL=useSCSubscribedIncubatorsManager.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from
|
|
1
|
+
import { useEffect, useMemo } from "react";
|
|
2
2
|
import { http, Endpoints } from '@selfcommunity/api-services';
|
|
3
3
|
import { Logger } from '@selfcommunity/utils';
|
|
4
4
|
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
@@ -18,7 +18,8 @@ import useSCCachingManager from './useSCCachingManager';
|
|
|
18
18
|
:::
|
|
19
19
|
*/
|
|
20
20
|
export default function useSCSubscribedIncubatorsManager(user) {
|
|
21
|
-
const { cache, updateCache, emptyCache, data, setData, loading, setLoading, isLoading } = useSCCachingManager();
|
|
21
|
+
const { cache, updateCache, emptyCache, data, setData, loading, setLoading, setUnLoading, isLoading } = useSCCachingManager();
|
|
22
|
+
const authUserId = user ? user.id : null;
|
|
22
23
|
/**
|
|
23
24
|
* Memoized refresh all subscribed
|
|
24
25
|
* It makes a single request to the server and retrieves
|
|
@@ -38,10 +39,9 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
38
39
|
if (res.status >= 300) {
|
|
39
40
|
return Promise.reject(res);
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.map(([k, v]) => parseInt(k)));
|
|
42
|
+
const incubatorIds = res.data.results.map((i) => i.id);
|
|
43
|
+
updateCache(incubatorIds);
|
|
44
|
+
setData(incubatorIds);
|
|
45
45
|
return Promise.resolve(res.data);
|
|
46
46
|
})
|
|
47
47
|
.catch((e) => {
|
|
@@ -55,7 +55,7 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
55
55
|
* Toggle action
|
|
56
56
|
*/
|
|
57
57
|
const subscribe = useMemo(() => (incubator) => {
|
|
58
|
-
setLoading(
|
|
58
|
+
setLoading(incubator.id);
|
|
59
59
|
return http
|
|
60
60
|
.request({
|
|
61
61
|
url: Endpoints.SubscribeToIncubator.url({ id: incubator.id }),
|
|
@@ -68,7 +68,7 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
68
68
|
updateCache([incubator.id]);
|
|
69
69
|
const isSubscribed = data.includes(incubator.id);
|
|
70
70
|
setData((prev) => (isSubscribed ? prev.filter((id) => id !== incubator.id) : [...[incubator.id], ...prev]));
|
|
71
|
-
|
|
71
|
+
setUnLoading(incubator.id);
|
|
72
72
|
return Promise.resolve(res.data);
|
|
73
73
|
});
|
|
74
74
|
}, [data, loading, cache]);
|
|
@@ -79,7 +79,7 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
79
79
|
* @param incubator
|
|
80
80
|
*/
|
|
81
81
|
const checkIsIncubatorFollowed = (incubator) => {
|
|
82
|
-
setLoading(
|
|
82
|
+
setLoading(incubator.id);
|
|
83
83
|
http
|
|
84
84
|
.request({
|
|
85
85
|
url: Endpoints.CheckIncubatorSubscription.url({ id: incubator.id }),
|
|
@@ -91,22 +91,19 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
91
91
|
}
|
|
92
92
|
updateCache([incubator.id]);
|
|
93
93
|
setData((prev) => (res.data.subscribed ? [...prev, ...[incubator.id]] : prev.filter((id) => id !== incubator.id)));
|
|
94
|
-
|
|
94
|
+
setUnLoading(incubator.id);
|
|
95
95
|
return Promise.resolve(res.data);
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// },
|
|
108
|
-
// [data, cache]
|
|
109
|
-
// );
|
|
98
|
+
/**
|
|
99
|
+
* Bypass remote check if the incubator is subscribed
|
|
100
|
+
*/
|
|
101
|
+
const getSubscriptionStatus = useMemo(() => (incubator) => {
|
|
102
|
+
const isSubscribed = incubator.subscribed || false;
|
|
103
|
+
updateCache([incubator.id]);
|
|
104
|
+
setData((prev) => (isSubscribed ? [...prev, ...[incubator.id]] : prev));
|
|
105
|
+
return isSubscribed;
|
|
106
|
+
}, [data, cache]);
|
|
110
107
|
/**
|
|
111
108
|
* Memoized isSubscribed
|
|
112
109
|
* If incubator is already in cache -> check if the incubator is in subscribed,
|
|
@@ -116,14 +113,26 @@ export default function useSCSubscribedIncubatorsManager(user) {
|
|
|
116
113
|
if (cache.includes(incubator.id)) {
|
|
117
114
|
return Boolean(data.includes(incubator.id));
|
|
118
115
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
if (authUserId) {
|
|
117
|
+
if ('subscribed' in incubator) {
|
|
118
|
+
return getSubscriptionStatus(incubator);
|
|
119
|
+
}
|
|
120
|
+
if (!isLoading(incubator)) {
|
|
121
|
+
checkIsIncubatorFollowed(incubator);
|
|
122
|
+
}
|
|
124
123
|
}
|
|
125
124
|
return false;
|
|
126
|
-
}, [data, loading, cache]);
|
|
125
|
+
}, [data, loading, cache, authUserId]);
|
|
126
|
+
/**
|
|
127
|
+
* Empty cache on logout
|
|
128
|
+
*/
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!authUserId) {
|
|
131
|
+
emptyCache();
|
|
132
|
+
}
|
|
133
|
+
}, [authUserId]);
|
|
134
|
+
if (!user) {
|
|
135
|
+
return { incubators: data, loading, isLoading };
|
|
136
|
+
}
|
|
127
137
|
return { incubators: data, loading, isLoading, subscribe, isSubscribed, refresh, emptyCache };
|
|
128
138
|
}
|
|
129
|
-
//# sourceMappingURL=useSCSubscribedIncubatorsManager.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SCUserType } from '@selfcommunity/types';
|
|
2
|
+
/**
|
|
3
|
+
:::info
|
|
4
|
+
This custom hook is used to check if the user is blocked by me or I am blocked by him.
|
|
5
|
+
:::
|
|
6
|
+
:::tipHow to use it:
|
|
7
|
+
|
|
8
|
+
Follow these steps:
|
|
9
|
+
```jsx
|
|
10
|
+
1. import useUserIsBlocked from '@selfcommunity/react-core';
|
|
11
|
+
2. const {blocked, loading: loadingBlockedBy} = useUserIsBlocked(user);
|
|
12
|
+
```
|
|
13
|
+
:::
|
|
14
|
+
*/
|
|
15
|
+
export default function useSCUserIsBlocked(user: SCUserType): {
|
|
16
|
+
blocked: boolean;
|
|
17
|
+
loading: boolean;
|
|
18
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import useSCFetchUserBlockedBy from './useSCFetchUserBlockedBy';
|
|
3
|
+
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
4
|
+
/**
|
|
5
|
+
:::info
|
|
6
|
+
This custom hook is used to check if the user is blocked by me or I am blocked by him.
|
|
7
|
+
:::
|
|
8
|
+
:::tipHow to use it:
|
|
9
|
+
|
|
10
|
+
Follow these steps:
|
|
11
|
+
```jsx
|
|
12
|
+
1. import useUserIsBlocked from '@selfcommunity/react-core';
|
|
13
|
+
2. const {blocked, loading: loadingBlockedBy} = useUserIsBlocked(user);
|
|
14
|
+
```
|
|
15
|
+
:::
|
|
16
|
+
*/
|
|
17
|
+
export default function useSCUserIsBlocked(user) {
|
|
18
|
+
// CONTEXT
|
|
19
|
+
const scUserContext = useSCUser();
|
|
20
|
+
// HOOKS
|
|
21
|
+
const { blockedBy, loading: loadingBlockedBy } = useSCFetchUserBlockedBy({ user });
|
|
22
|
+
// CONST
|
|
23
|
+
const isMe = useMemo(() => scUserContext.user && user.id === scUserContext.user.id, [scUserContext.user, user]);
|
|
24
|
+
// Status blocked
|
|
25
|
+
const blocked = !isMe && user && Boolean((scUserContext.user && scUserContext.managers.blockedUsers.isBlocked(user)) || blockedBy);
|
|
26
|
+
// Status loading
|
|
27
|
+
const loading = scUserContext.user && (scUserContext.managers.blockedUsers.isLoading() || loadingBlockedBy);
|
|
28
|
+
return { blocked, loading };
|
|
29
|
+
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { SnackbarKey } from 'notistack';
|
|
2
|
+
/**
|
|
3
|
+
* Browser supported on backend
|
|
4
|
+
*/
|
|
5
|
+
export declare const CHROME_BROWSER_TYPE = "chrome";
|
|
6
|
+
export declare const FIREFOX_BROWSER_TYPE = "firefox";
|
|
7
|
+
export declare const OPERA_BROWSER_TYPE = "opera";
|
|
8
|
+
export declare const EDGE_BROWSER_TYPE = "edge";
|
|
9
|
+
export declare const DEFAULT_BROWSER_TYPE = "chrome";
|
|
10
|
+
export declare const SUPPORTED_BROWSER_TYPES: string[];
|
|
1
11
|
/**
|
|
2
12
|
:::info
|
|
3
|
-
This custom hook is used to
|
|
13
|
+
This custom hook is used to init web push messaging.
|
|
4
14
|
:::
|
|
5
15
|
*/
|
|
6
16
|
export default function useSCWebPushMessaging(): {
|
|
7
17
|
wpSubscription: any;
|
|
18
|
+
requestNotificationPermission: (snackbarId: SnackbarKey | null) => void;
|
|
8
19
|
};
|
|
9
|
-
//# sourceMappingURL=useSCWebPushMessaging.d.ts.map
|
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
import { useContext, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { useSCContext } from '../components/provider/SCContextProvider';
|
|
3
3
|
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
4
4
|
import { Logger } from '@selfcommunity/utils';
|
|
5
|
+
import Button from '@mui/material/Button';
|
|
5
6
|
import { loadVersionBrowser, urlB64ToUint8Array } from '@selfcommunity/utils';
|
|
6
7
|
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
7
8
|
import { http, Endpoints } from '@selfcommunity/api-services';
|
|
8
9
|
import { WEB_PUSH_NOTIFICATION_DEVICE_TYPE } from '../constants/Device';
|
|
9
10
|
import { SCPreferencesContext } from '../components/provider/SCPreferencesProvider';
|
|
11
|
+
import { useSnackbar } from 'notistack';
|
|
10
12
|
import * as SCPreferences from '../constants/Preferences';
|
|
13
|
+
import { NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE } from '../constants/Notifications';
|
|
14
|
+
import Cookies from 'js-cookie';
|
|
15
|
+
import { useIntl } from 'react-intl';
|
|
16
|
+
import { isWebPushMessagingEnabled } from '../utils/notification';
|
|
17
|
+
/**
|
|
18
|
+
* Browser supported on backend
|
|
19
|
+
*/
|
|
20
|
+
export const CHROME_BROWSER_TYPE = 'chrome';
|
|
21
|
+
export const FIREFOX_BROWSER_TYPE = 'firefox';
|
|
22
|
+
export const OPERA_BROWSER_TYPE = 'opera';
|
|
23
|
+
export const EDGE_BROWSER_TYPE = 'edge';
|
|
24
|
+
export const DEFAULT_BROWSER_TYPE = CHROME_BROWSER_TYPE;
|
|
25
|
+
export const SUPPORTED_BROWSER_TYPES = [CHROME_BROWSER_TYPE, FIREFOX_BROWSER_TYPE, OPERA_BROWSER_TYPE, EDGE_BROWSER_TYPE];
|
|
11
26
|
/**
|
|
12
27
|
:::info
|
|
13
|
-
This custom hook is used to
|
|
28
|
+
This custom hook is used to init web push messaging.
|
|
14
29
|
:::
|
|
15
30
|
*/
|
|
16
31
|
export default function useSCWebPushMessaging() {
|
|
@@ -18,6 +33,8 @@ export default function useSCWebPushMessaging() {
|
|
|
18
33
|
const scContext = useSCContext();
|
|
19
34
|
const scUserContext = useSCUser();
|
|
20
35
|
const scPreferencesContext = useContext(SCPreferencesContext);
|
|
36
|
+
const intl = useIntl();
|
|
37
|
+
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
|
21
38
|
// STATE
|
|
22
39
|
const [wpSubscription, setWpSubscription] = useState(null);
|
|
23
40
|
// REFS
|
|
@@ -28,10 +45,43 @@ export default function useSCWebPushMessaging() {
|
|
|
28
45
|
: SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY in scPreferencesContext.preferences
|
|
29
46
|
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_PUBLIC_KEY].value
|
|
30
47
|
: null;
|
|
31
|
-
const
|
|
48
|
+
const webPushPreferenceEnabled = SCPreferences.PROVIDERS_WEB_PUSH_ENABLED in scPreferencesContext.preferences &&
|
|
32
49
|
scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
33
50
|
? scPreferencesContext.preferences[SCPreferences.PROVIDERS_WEB_PUSH_ENABLED].value
|
|
34
51
|
: false;
|
|
52
|
+
/**
|
|
53
|
+
* Show custom Snackbar dialog to request permission
|
|
54
|
+
* User action required for some browser (ex. Safari)
|
|
55
|
+
*/
|
|
56
|
+
const showCustomRequestNotificationSnackbar = () => {
|
|
57
|
+
if (!Cookies.get(NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE)) {
|
|
58
|
+
enqueueSnackbar(intl.formatMessage({ id: 'ui.webPushNotification.requestPermission', defaultMessage: 'ui.webPushNotification.requestPermission' }), {
|
|
59
|
+
action: (snackbarId) => (React.createElement(React.Fragment, null,
|
|
60
|
+
React.createElement(Button, { size: "small", sx: { color: '#FFF' }, onClick: () => requestNotificationPermission(snackbarId) }, intl.formatMessage({ id: 'ui.webPushNotification.allow', defaultMessage: 'ui.webPushNotification.allow' })),
|
|
61
|
+
React.createElement(Button, { size: "small", sx: { color: '#FFF' }, onClick: () => closeRequestNotificationSnackbar(snackbarId) }, intl.formatMessage({ id: 'ui.webPushNotification.block', defaultMessage: 'ui.webPushNotification.block' })))),
|
|
62
|
+
variant: 'default',
|
|
63
|
+
anchorOrigin: { horizontal: 'center', vertical: 'bottom' },
|
|
64
|
+
preventDuplicate: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
Logger.info(SCOPE_SC_CORE, 'Skip show the dialog to request Web Push Notifications grant permission');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Close the SnackBar dialog if the request notification permission
|
|
73
|
+
* came from the custom dialog
|
|
74
|
+
* @param snackbarId
|
|
75
|
+
*/
|
|
76
|
+
const closeRequestNotificationSnackbar = (snackbarId) => {
|
|
77
|
+
if (snackbarId) {
|
|
78
|
+
closeSnackbar(snackbarId);
|
|
79
|
+
// To set expiration in minutes:
|
|
80
|
+
// let inFifteenMinutes = new Date(new Date().getTime() + 15 * 60 * 1000);
|
|
81
|
+
// {expires: inFifteenMinutes}
|
|
82
|
+
Cookies.set(NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE, '1', { expires: 1 });
|
|
83
|
+
}
|
|
84
|
+
};
|
|
35
85
|
/**
|
|
36
86
|
* perform update the Subscription
|
|
37
87
|
* @param data
|
|
@@ -52,20 +102,45 @@ export default function useSCWebPushMessaging() {
|
|
|
52
102
|
return Promise.resolve(res.data);
|
|
53
103
|
});
|
|
54
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Return browser type
|
|
107
|
+
* Fallback to DEFAULT_BROWSER_TYPE if the browser detected not in SUPPORTED_BROWSER_TYPES
|
|
108
|
+
*/
|
|
109
|
+
const getBrowserType = (browser) => {
|
|
110
|
+
if (SUPPORTED_BROWSER_TYPES.indexOf(browser.name) < 0) {
|
|
111
|
+
return DEFAULT_BROWSER_TYPE;
|
|
112
|
+
}
|
|
113
|
+
return browser.name;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Return registrationId based on browser type and subscription
|
|
117
|
+
* Fallback to subscription.endpoint if the browser detected not in SUPPORTED_BROWSER_TYPES
|
|
118
|
+
*/
|
|
119
|
+
const getRegistrationId = (browser, sub) => {
|
|
120
|
+
if (SUPPORTED_BROWSER_TYPES.indexOf(browser.name) < 0) {
|
|
121
|
+
return sub.endpoint;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
const endpointParts = sub.endpoint.split('/');
|
|
125
|
+
return endpointParts[endpointParts.length - 1];
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
return sub.endpoint;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
55
131
|
/**
|
|
56
132
|
* updateSubscriptionOnServer to sync current subscription
|
|
57
133
|
* @param sub
|
|
134
|
+
* @param remove
|
|
58
135
|
*/
|
|
59
136
|
const updateSubscriptionOnServer = (sub, remove) => {
|
|
60
137
|
const browser = loadVersionBrowser();
|
|
61
|
-
const endpointParts = sub.endpoint.split('/');
|
|
62
|
-
const registration_id = endpointParts[endpointParts.length - 1];
|
|
63
138
|
const data = {
|
|
64
|
-
browser: browser.
|
|
139
|
+
browser: getBrowserType(browser).toUpperCase(),
|
|
65
140
|
p256dh: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('p256dh')))),
|
|
66
141
|
auth: btoa(String.fromCharCode.apply(null, new Uint8Array(sub.getKey('auth')))),
|
|
67
142
|
user: scUserContext.user ? scUserContext.user.username : '',
|
|
68
|
-
registration_id:
|
|
143
|
+
registration_id: getRegistrationId(browser, sub),
|
|
69
144
|
};
|
|
70
145
|
return performUpdateSubscription(data, remove)
|
|
71
146
|
.then((res) => {
|
|
@@ -73,6 +148,7 @@ export default function useSCWebPushMessaging() {
|
|
|
73
148
|
setWpSubscription(null);
|
|
74
149
|
}
|
|
75
150
|
else {
|
|
151
|
+
Logger.info(SCOPE_SC_CORE, 'Web Push Notifications subscription created successfully');
|
|
76
152
|
setWpSubscription(res);
|
|
77
153
|
}
|
|
78
154
|
})
|
|
@@ -86,87 +162,97 @@ export default function useSCWebPushMessaging() {
|
|
|
86
162
|
*/
|
|
87
163
|
const unsubscribe = (callback = null) => {
|
|
88
164
|
navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
165
|
+
if (serviceWorkerRegistration) {
|
|
166
|
+
// To unsubscribe from push messaging, you need get the
|
|
167
|
+
// subscription object, which you can call unsubscribe() on.
|
|
168
|
+
serviceWorkerRegistration.pushManager
|
|
169
|
+
.getSubscription()
|
|
170
|
+
.then((pushSubscription) => {
|
|
171
|
+
// Check we have a subscription to unsubscribe
|
|
172
|
+
if (!pushSubscription) {
|
|
173
|
+
// No subscription object, so set the state
|
|
174
|
+
// to allow the user to subscribe to push
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
// We have a subscription, so call unsubscribe on it
|
|
178
|
+
pushSubscription
|
|
179
|
+
.unsubscribe()
|
|
180
|
+
.then(() => {
|
|
181
|
+
Logger.info(SCOPE_SC_CORE, 'Unsubscription successfully');
|
|
182
|
+
// Request to server to remove
|
|
183
|
+
// the users data from your data store so you
|
|
184
|
+
// don't attempt to send them push messages anymore
|
|
185
|
+
void updateSubscriptionOnServer(pushSubscription, true).then(() => {
|
|
186
|
+
callback && callback();
|
|
187
|
+
});
|
|
188
|
+
})
|
|
189
|
+
.catch(function (e) {
|
|
190
|
+
// We failed to unsubscribe, this can lead to
|
|
191
|
+
// an unusual state, so may be best to remove
|
|
192
|
+
// the subscription id from your data store and
|
|
193
|
+
// inform the user that you disabled push
|
|
194
|
+
Logger.info(SCOPE_SC_CORE, `Error on removing web push notification subscription.`);
|
|
195
|
+
console.log(e);
|
|
110
196
|
});
|
|
111
197
|
})
|
|
112
198
|
.catch(function (e) {
|
|
113
|
-
|
|
114
|
-
// an unusual state, so may be best to remove
|
|
115
|
-
// the subscription id from your data store and
|
|
116
|
-
// inform the user that you disabled push
|
|
117
|
-
Logger.info(SCOPE_SC_CORE, `Unsubscription error.`);
|
|
118
|
-
console.log(e);
|
|
199
|
+
Logger.info(SCOPE_SC_CORE, `Error thrown while unsubscribing from push messaging. ${e}`);
|
|
119
200
|
});
|
|
120
|
-
}
|
|
121
|
-
.catch(function (e) {
|
|
122
|
-
Logger.info(SCOPE_SC_CORE, `Error thrown while unsubscribing from push messaging. ${e}`);
|
|
123
|
-
});
|
|
201
|
+
}
|
|
124
202
|
});
|
|
125
203
|
};
|
|
126
204
|
/**
|
|
127
205
|
* Get subscription
|
|
128
206
|
*/
|
|
129
207
|
const subscribe = () => {
|
|
130
|
-
navigator.serviceWorker.
|
|
131
|
-
serviceWorkerRegistration
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
updateSubscriptionOnServer(subscription, false);
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
.catch(function (e) {
|
|
142
|
-
if (Notification.permission === 'denied') {
|
|
143
|
-
// The user denied the notification permission which
|
|
144
|
-
// means we failed to subscribe and the user will need
|
|
145
|
-
// to manually change the notification permission to
|
|
146
|
-
// subscribe to push messages
|
|
147
|
-
Logger.info(SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
// A problem occurred with the subscription
|
|
151
|
-
subAttempts.current += 1;
|
|
152
|
-
Logger.info(SCOPE_SC_CORE, `Unable to subscribe(${subAttempts.current}) to push. ${e}`);
|
|
153
|
-
if (subAttempts.current < 3) {
|
|
154
|
-
unsubscribe(() => subscribe());
|
|
208
|
+
navigator.serviceWorker.getRegistration().then(function (serviceWorkerRegistration) {
|
|
209
|
+
if (serviceWorkerRegistration) {
|
|
210
|
+
// service worker is registered
|
|
211
|
+
serviceWorkerRegistration.pushManager
|
|
212
|
+
.subscribe({ userVisibleOnly: true, applicationServerKey: urlB64ToUint8Array(applicationServerKey) })
|
|
213
|
+
.then(function (subscription) {
|
|
214
|
+
if (!subscription) {
|
|
215
|
+
Logger.info(SCOPE_SC_CORE, 'We aren’t subscribed to push.');
|
|
155
216
|
}
|
|
156
217
|
else {
|
|
157
|
-
|
|
218
|
+
void updateSubscriptionOnServer(subscription, false);
|
|
158
219
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
220
|
+
})
|
|
221
|
+
.catch(function (e) {
|
|
222
|
+
console.log(e);
|
|
223
|
+
if (Notification.permission === 'denied') {
|
|
224
|
+
// The user denied the notification permission which
|
|
225
|
+
// means we failed to subscribe and the user will need
|
|
226
|
+
// to manually change the notification permission to
|
|
227
|
+
// subscribe to push messages
|
|
228
|
+
Logger.info(SCOPE_SC_CORE, 'Permission for Web Push Notifications was denied');
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
// A problem occurred with the subscription
|
|
232
|
+
subAttempts.current += 1;
|
|
233
|
+
Logger.info(SCOPE_SC_CORE, `Unable to subscribe(${subAttempts.current}) to push. ${e}`);
|
|
234
|
+
if (subAttempts.current < 3) {
|
|
235
|
+
unsubscribe(() => subscribe());
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
Logger.info(SCOPE_SC_CORE, `Unable to subscribe to Web Push Notification. ${e}`);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
Logger.info(SCOPE_SC_CORE, `To receive Web Push Notifications the service worker must be registered.`);
|
|
245
|
+
}
|
|
161
246
|
});
|
|
162
247
|
};
|
|
163
248
|
/**
|
|
164
249
|
* Request web push notification permission
|
|
165
250
|
* @type {(function(): void)|*}
|
|
166
251
|
*/
|
|
167
|
-
const requestNotificationPermission = () => {
|
|
252
|
+
const requestNotificationPermission = (snackbarId) => {
|
|
168
253
|
if (Notification.permission !== 'granted') {
|
|
169
|
-
Notification.requestPermission()
|
|
254
|
+
Notification.requestPermission()
|
|
255
|
+
.then(function (permission) {
|
|
170
256
|
if (permission === 'granted') {
|
|
171
257
|
navigator.serviceWorker.ready.then((serviceWorkerRegistration) => {
|
|
172
258
|
// Do we already have a push message subscription?
|
|
@@ -180,7 +266,7 @@ export default function useSCWebPushMessaging() {
|
|
|
180
266
|
return;
|
|
181
267
|
}
|
|
182
268
|
// Keep your server in sync with the latest subscription
|
|
183
|
-
updateSubscriptionOnServer(subscription, false);
|
|
269
|
+
void updateSubscriptionOnServer(subscription, false);
|
|
184
270
|
})
|
|
185
271
|
.catch((err) => {
|
|
186
272
|
Logger.info(SCOPE_SC_CORE, 'Error during getSubscription()');
|
|
@@ -191,8 +277,13 @@ export default function useSCWebPushMessaging() {
|
|
|
191
277
|
else {
|
|
192
278
|
Logger.info(SCOPE_SC_CORE, 'Permission for Notifications was denied');
|
|
193
279
|
}
|
|
280
|
+
})
|
|
281
|
+
.catch((err) => {
|
|
282
|
+
console.log(err);
|
|
283
|
+
Logger.info(SCOPE_SC_CORE, 'Request web push permission by a user generated gesture');
|
|
194
284
|
});
|
|
195
285
|
}
|
|
286
|
+
closeRequestNotificationSnackbar(snackbarId);
|
|
196
287
|
};
|
|
197
288
|
/**
|
|
198
289
|
* Initialize state
|
|
@@ -201,7 +292,7 @@ export default function useSCWebPushMessaging() {
|
|
|
201
292
|
/**
|
|
202
293
|
* Check if Notifications supported in the service worker
|
|
203
294
|
*/
|
|
204
|
-
if (
|
|
295
|
+
if (typeof ServiceWorkerRegistration === 'undefined') {
|
|
205
296
|
Logger.info(SCOPE_SC_CORE, "Notifications aren't supported.");
|
|
206
297
|
return;
|
|
207
298
|
}
|
|
@@ -210,22 +301,27 @@ export default function useSCWebPushMessaging() {
|
|
|
210
301
|
* so your development environment must serve content over HTTPS to match a production environment.
|
|
211
302
|
* Check if push messaging is supported.
|
|
212
303
|
*/
|
|
213
|
-
if (!('PushManager' in window && 'serviceWorker' in navigator)) {
|
|
304
|
+
if (!('PushManager' in window && 'serviceWorker' in navigator && 'Notification' in window)) {
|
|
214
305
|
Logger.info(SCOPE_SC_CORE, "Service Worker or Push messaging aren't supported.");
|
|
215
306
|
return;
|
|
216
307
|
}
|
|
217
308
|
/**
|
|
218
309
|
* Check the current Notification permission.
|
|
219
|
-
* If
|
|
310
|
+
* If it's denied, it's a permanent block until the user changes the permission
|
|
220
311
|
*/
|
|
221
312
|
if (Notification.permission === 'denied') {
|
|
222
|
-
Logger.info(SCOPE_SC_CORE, 'The user has blocked
|
|
313
|
+
Logger.info(SCOPE_SC_CORE, 'The user has blocked Web Push Notifications.');
|
|
223
314
|
return;
|
|
224
315
|
}
|
|
225
316
|
else {
|
|
226
317
|
if (Notification.permission === 'default') {
|
|
227
|
-
Logger.info(SCOPE_SC_CORE, 'Request permission
|
|
228
|
-
|
|
318
|
+
Logger.info(SCOPE_SC_CORE, 'Request permission');
|
|
319
|
+
if (navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')) {
|
|
320
|
+
showCustomRequestNotificationSnackbar();
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
requestNotificationPermission(null);
|
|
324
|
+
}
|
|
229
325
|
}
|
|
230
326
|
else if (Notification.permission === 'granted') {
|
|
231
327
|
subscribe();
|
|
@@ -237,22 +333,29 @@ export default function useSCWebPushMessaging() {
|
|
|
237
333
|
* If web push enabled, applicationServerKey and user is logged, check subscription
|
|
238
334
|
*/
|
|
239
335
|
useEffect(() => {
|
|
240
|
-
if (!wpSubscription &&
|
|
241
|
-
if (!
|
|
242
|
-
Logger.warn(SCOPE_SC_CORE, '
|
|
336
|
+
if (!wpSubscription && scUserContext.user) {
|
|
337
|
+
if (!isWebPushMessagingEnabled()) {
|
|
338
|
+
Logger.warn(SCOPE_SC_CORE, 'Mobile native notifications replace web push messages with this settings.');
|
|
339
|
+
}
|
|
340
|
+
else if (!webPushPreferenceEnabled || scContext.settings.notifications.webPushMessaging.disableToastMessage) {
|
|
341
|
+
Logger.warn(SCOPE_SC_CORE, 'This instance is not configured to support web push notifications or they have been disabled.');
|
|
243
342
|
}
|
|
244
343
|
else if (!applicationServerKey) {
|
|
245
344
|
Logger.warn(SCOPE_SC_CORE, 'Invalid or missing applicationServerKey. Check the configuration that is passed to the SCContextProvider.');
|
|
246
345
|
}
|
|
247
346
|
else {
|
|
347
|
+
Logger.info(SCOPE_SC_CORE, 'Initialize web push notification.');
|
|
248
348
|
initialiseState();
|
|
249
349
|
}
|
|
250
350
|
}
|
|
251
|
-
if (!scUserContext.user && wpSubscription) {
|
|
351
|
+
if ((!scUserContext.user || !isWebPushMessagingEnabled()) && wpSubscription) {
|
|
252
352
|
// Unsubscribe if user not in session
|
|
253
|
-
unsubscribe()
|
|
353
|
+
unsubscribe(() => {
|
|
354
|
+
if (navigator.userAgent.includes('Safari') && !navigator.userAgent.includes('Chrome')) {
|
|
355
|
+
Cookies.remove(NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
254
358
|
}
|
|
255
359
|
}, [scUserContext.user, scContext.settings.notifications.webPushMessaging, wpSubscription]);
|
|
256
|
-
return { wpSubscription };
|
|
360
|
+
return { wpSubscription, requestNotificationPermission };
|
|
257
361
|
}
|
|
258
|
-
//# sourceMappingURL=useSCWebPushMessaging.js.map
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
import { WSClientType } from '@selfcommunity/utils';
|
|
3
3
|
/**
|
|
4
4
|
:::info
|
|
5
|
-
This custom hook is used to
|
|
5
|
+
This custom hook is used to init web socket.
|
|
6
6
|
:::
|
|
7
7
|
*/
|
|
8
8
|
export default function useSCWebSocket(): {
|
|
9
9
|
wsInstance: WSClientType;
|
|
10
10
|
setWsInstance: import("react").Dispatch<import("react").SetStateAction<WSClientType>>;
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=useSCWebSocket.d.ts.map
|
|
@@ -8,7 +8,7 @@ import { WS_FACILITY_NOTIFY, WS_SUB_PROTOCOL_PREFIX, WS_HEARTBEAT_MESSAGE, WS_PR
|
|
|
8
8
|
import PubSub from 'pubsub-js';
|
|
9
9
|
/**
|
|
10
10
|
:::info
|
|
11
|
-
This custom hook is used to
|
|
11
|
+
This custom hook is used to init web socket.
|
|
12
12
|
:::
|
|
13
13
|
*/
|
|
14
14
|
export default function useSCWebSocket() {
|
|
@@ -108,4 +108,3 @@ export default function useSCWebSocket() {
|
|
|
108
108
|
};
|
|
109
109
|
return { wsInstance, setWsInstance };
|
|
110
110
|
}
|
|
111
|
-
//# sourceMappingURL=useSCWebSocket.js.map
|