@selfcommunity/react-core 0.4.0-alpha.11 → 0.4.0-alpha.111
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 -77
- 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 -73
- 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
|
@@ -16,25 +16,28 @@ import { SCUserType } from '@selfcommunity/types';
|
|
|
16
16
|
*/
|
|
17
17
|
export default function useSCConnectionsManager(user?: SCUserType): {
|
|
18
18
|
connections: any[];
|
|
19
|
-
loading:
|
|
20
|
-
isLoading: (
|
|
19
|
+
loading: any[];
|
|
20
|
+
isLoading: (v: number | {
|
|
21
21
|
id: number;
|
|
22
22
|
}) => boolean;
|
|
23
23
|
status?: undefined;
|
|
24
24
|
requestConnection?: undefined;
|
|
25
|
+
cancelRequestConnection?: undefined;
|
|
25
26
|
acceptConnection?: undefined;
|
|
27
|
+
removeConnection?: undefined;
|
|
26
28
|
refresh?: undefined;
|
|
27
29
|
emptyCache?: undefined;
|
|
28
30
|
} | {
|
|
29
31
|
connections: any[];
|
|
30
|
-
loading:
|
|
31
|
-
isLoading: (
|
|
32
|
+
loading: any[];
|
|
33
|
+
isLoading: (v: number | {
|
|
32
34
|
id: number;
|
|
33
35
|
}) => boolean;
|
|
34
36
|
status: (user: SCUserType) => string;
|
|
35
37
|
requestConnection: (user: SCUserType) => Promise<any>;
|
|
38
|
+
cancelRequestConnection: (user: SCUserType) => Promise<any>;
|
|
36
39
|
acceptConnection: (user: SCUserType) => Promise<any>;
|
|
40
|
+
removeConnection: (user: SCUserType) => Promise<any>;
|
|
37
41
|
refresh: () => void;
|
|
38
42
|
emptyCache: () => void;
|
|
39
43
|
};
|
|
40
|
-
//# sourceMappingURL=useSCConnectionsManager.d.ts.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
6
4
|
const react_1 = require("react");
|
|
7
5
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
8
6
|
const types_1 = require("@selfcommunity/types");
|
|
@@ -10,18 +8,11 @@ const utils_1 = require("@selfcommunity/utils");
|
|
|
10
8
|
const Errors_1 = require("../constants/Errors");
|
|
11
9
|
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
12
10
|
const Preferences_1 = require("../constants/Preferences");
|
|
13
|
-
const useSCCachingManager_1 = __importDefault(require("./useSCCachingManager"));
|
|
14
|
-
const pubsub_js_1 = __importDefault(require("pubsub-js"));
|
|
11
|
+
const useSCCachingManager_1 = tslib_1.__importDefault(require("./useSCCachingManager"));
|
|
12
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
15
13
|
const Notification_1 = require("../constants/Notification");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Check if the user status is 'connected', 'sent_connection_request'
|
|
19
|
-
* 'received_connection_request', to update the cache and data
|
|
20
|
-
*/
|
|
21
|
-
const STATUS_CONNECTED = 'connected';
|
|
22
|
-
const STATUS_DISCONNECTED = 'disconnected';
|
|
23
|
-
const STATUS_CONNECTION_REQUEST_SENT = 'sent_connection_request';
|
|
24
|
-
const STATUS_CONNECTION_REQUEST_RECEIVED = 'received_connection_request';
|
|
14
|
+
const types_2 = require("@selfcommunity/types");
|
|
15
|
+
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
25
16
|
/**
|
|
26
17
|
:::info
|
|
27
18
|
This custom hook is used to manage to manage friends.
|
|
@@ -38,52 +29,55 @@ const STATUS_CONNECTION_REQUEST_RECEIVED = 'received_connection_request';
|
|
|
38
29
|
:::
|
|
39
30
|
*/
|
|
40
31
|
function useSCConnectionsManager(user) {
|
|
41
|
-
const { cache, updateCache, emptyCache, data, setData, loading, setLoading, isLoading } = (0, useSCCachingManager_1.default)();
|
|
32
|
+
const { cache, updateCache, emptyCache, data, setData, loading, setLoading, setUnLoading, isLoading } = (0, useSCCachingManager_1.default)();
|
|
42
33
|
const scPreferencesContext = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
34
|
+
const authUserId = user ? user.id : null;
|
|
43
35
|
const connectionsDisabled = Preferences_1.CONFIGURATIONS_FOLLOW_ENABLED in scPreferencesContext.preferences && scPreferencesContext.preferences[Preferences_1.CONFIGURATIONS_FOLLOW_ENABLED].value;
|
|
44
36
|
const notificationConnAcceptSubscription = (0, react_1.useRef)(null);
|
|
45
37
|
const notificationConnRequestSubscription = (0, react_1.useRef)(null);
|
|
46
38
|
const notificationConnRemoveSubscription = (0, react_1.useRef)(null);
|
|
39
|
+
const notificationConnRequestCancelSubscription = (0, react_1.useRef)(null);
|
|
47
40
|
/**
|
|
48
|
-
* Notification subscriber
|
|
41
|
+
* Notification subscriber handler
|
|
49
42
|
* @param msg
|
|
50
43
|
* @param data
|
|
51
44
|
*/
|
|
52
|
-
const notificationSubscriber = (msg,
|
|
53
|
-
if (data.connection
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
k: k === data.data.connection_id ? STATUS_DISCONNECTED : v,
|
|
69
|
-
}));
|
|
45
|
+
const notificationSubscriber = (msg, dataMsg) => {
|
|
46
|
+
if (dataMsg.data.connection !== undefined) {
|
|
47
|
+
let _upd;
|
|
48
|
+
switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
|
|
49
|
+
case types_1.SCNotificationTypologyType.CONNECTION_REQUEST:
|
|
50
|
+
_upd = { user: 'request_user', state: types_2.SCConnectionStatus.CONNECTION_REQUEST_RECEIVED };
|
|
51
|
+
break;
|
|
52
|
+
case types_1.SCNotificationTypologyType.CONNECTION_CANCEL_REQUEST:
|
|
53
|
+
_upd = { user: 'cancel_request_user', state: null };
|
|
54
|
+
break;
|
|
55
|
+
case types_1.SCNotificationTypologyType.CONNECTION_ACCEPT:
|
|
56
|
+
_upd = { user: 'accept_user', state: types_2.SCConnectionStatus.CONNECTED };
|
|
57
|
+
break;
|
|
58
|
+
case types_1.SCNotificationTypologyType.CONNECTION_REMOVE:
|
|
59
|
+
_upd = { user: 'remove_user', state: null };
|
|
60
|
+
break;
|
|
70
61
|
}
|
|
71
|
-
|
|
62
|
+
updateCache([dataMsg.data[_upd.user].id]);
|
|
63
|
+
setData((prev) => getDataUpdated(prev, dataMsg.data[_upd.user].id, _upd.state));
|
|
72
64
|
}
|
|
73
65
|
};
|
|
74
66
|
/**
|
|
75
67
|
* Subscribe to notification types user_follow, user_unfollow
|
|
76
68
|
*/
|
|
77
|
-
(0,
|
|
69
|
+
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
78
70
|
notificationConnAcceptSubscription.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.CONNECTION_ACCEPT}`, notificationSubscriber);
|
|
79
71
|
notificationConnRequestSubscription.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.CONNECTION_REQUEST}`, notificationSubscriber);
|
|
72
|
+
notificationConnRequestCancelSubscription.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.CONNECTION_CANCEL_REQUEST}`, notificationSubscriber);
|
|
80
73
|
notificationConnRemoveSubscription.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.CONNECTION_REMOVE}`, notificationSubscriber);
|
|
81
74
|
return () => {
|
|
82
75
|
pubsub_js_1.default.unsubscribe(notificationConnAcceptSubscription.current);
|
|
83
76
|
pubsub_js_1.default.unsubscribe(notificationConnRequestSubscription.current);
|
|
77
|
+
pubsub_js_1.default.unsubscribe(notificationConnRequestCancelSubscription.current);
|
|
84
78
|
pubsub_js_1.default.unsubscribe(notificationConnRemoveSubscription.current);
|
|
85
79
|
};
|
|
86
|
-
}, []);
|
|
80
|
+
}, [data]);
|
|
87
81
|
/**
|
|
88
82
|
* Memoized refresh all connections
|
|
89
83
|
* It makes a single request to the server and retrieves
|
|
@@ -92,7 +86,7 @@ function useSCConnectionsManager(user) {
|
|
|
92
86
|
*/
|
|
93
87
|
const refresh = (0, react_1.useMemo)(() => () => {
|
|
94
88
|
emptyCache();
|
|
95
|
-
if (
|
|
89
|
+
if (authUserId && cache.length > 0) {
|
|
96
90
|
// Only if user is authenticated
|
|
97
91
|
api_services_1.http
|
|
98
92
|
.request({
|
|
@@ -105,9 +99,7 @@ function useSCConnectionsManager(user) {
|
|
|
105
99
|
return Promise.reject(res);
|
|
106
100
|
}
|
|
107
101
|
updateCache(Object.keys(res.data.connection_statuses).map((id) => parseInt(id)));
|
|
108
|
-
setData(Object.
|
|
109
|
-
.filter(([k, v]) => v !== null)
|
|
110
|
-
.map(([k, v]) => ({ [parseInt(k)]: v })));
|
|
102
|
+
setData(Object.keys(res.data.connection_statuses).map((k) => ({ [k]: res.data.connection_statuses[k] })));
|
|
111
103
|
return Promise.resolve(res.data);
|
|
112
104
|
})
|
|
113
105
|
.catch((e) => {
|
|
@@ -115,64 +107,65 @@ function useSCConnectionsManager(user) {
|
|
|
115
107
|
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, e);
|
|
116
108
|
});
|
|
117
109
|
}
|
|
118
|
-
}, [data,
|
|
110
|
+
}, [data, authUserId, cache]);
|
|
119
111
|
/**
|
|
120
112
|
* Memoized Request connection
|
|
121
113
|
*/
|
|
122
|
-
const
|
|
123
|
-
setLoading(
|
|
124
|
-
if (getCurrentStatus(user) === STATUS_CONNECTION_REQUEST_RECEIVED) {
|
|
125
|
-
return acceptConnection(user);
|
|
126
|
-
}
|
|
114
|
+
const handleRequest = (0, react_1.useMemo)(() => (user, endpoint) => {
|
|
115
|
+
setLoading(user.id);
|
|
127
116
|
return api_services_1.http
|
|
128
117
|
.request({
|
|
129
|
-
url:
|
|
130
|
-
method:
|
|
118
|
+
url: endpoint.url({ id: user.id }),
|
|
119
|
+
method: endpoint.method,
|
|
131
120
|
})
|
|
132
121
|
.then((res) => {
|
|
133
122
|
if (res.status >= 300) {
|
|
134
123
|
return Promise.reject(res);
|
|
135
124
|
}
|
|
136
125
|
updateCache([user.id]);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}));
|
|
140
|
-
setData(_data);
|
|
141
|
-
setLoading((prev) => prev.filter((u) => u !== user.id));
|
|
126
|
+
setData((prev) => getDataUpdated(prev, user.id, res.data.connection_status));
|
|
127
|
+
setUnLoading(user.id);
|
|
142
128
|
return Promise.resolve(res.data);
|
|
129
|
+
})
|
|
130
|
+
.catch((e) => {
|
|
131
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, e);
|
|
132
|
+
if (e && e.response && e.response && e.response.status && e.response.status === 403) {
|
|
133
|
+
setUnLoading(user.id);
|
|
134
|
+
return Promise.reject(e);
|
|
135
|
+
}
|
|
136
|
+
return checkUserConnectionStatus(user);
|
|
143
137
|
});
|
|
144
138
|
}, [data, loading, cache]);
|
|
139
|
+
/**
|
|
140
|
+
* Memoized Request connection
|
|
141
|
+
*/
|
|
142
|
+
const requestConnection = (0, react_1.useMemo)(() => (user) => {
|
|
143
|
+
return handleRequest(user, api_services_1.Endpoints.UserRequestConnection);
|
|
144
|
+
}, [handleRequest]);
|
|
145
|
+
/**
|
|
146
|
+
* Memoized cancel request connection
|
|
147
|
+
*/
|
|
148
|
+
const cancelRequestConnection = (0, react_1.useMemo)(() => (user) => {
|
|
149
|
+
return handleRequest(user, api_services_1.Endpoints.UserCancelRequestConnection);
|
|
150
|
+
}, [handleRequest]);
|
|
151
|
+
/**
|
|
152
|
+
* Memoized Remove connection
|
|
153
|
+
*/
|
|
154
|
+
const removeConnection = (0, react_1.useMemo)(() => (user) => {
|
|
155
|
+
return handleRequest(user, api_services_1.Endpoints.UserRemoveConnection);
|
|
156
|
+
}, [handleRequest]);
|
|
145
157
|
/**
|
|
146
158
|
* Memoized Accept Request connection
|
|
147
159
|
*/
|
|
148
160
|
const acceptConnection = (0, react_1.useMemo)(() => (user) => {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return api_services_1.http
|
|
152
|
-
.request({
|
|
153
|
-
url: api_services_1.Endpoints.UserAcceptRequestConnection.url({ id: user.id }),
|
|
154
|
-
method: api_services_1.Endpoints.UserAcceptRequestConnection.method,
|
|
155
|
-
})
|
|
156
|
-
.then((res) => {
|
|
157
|
-
if (res.status >= 300) {
|
|
158
|
-
return Promise.reject(res);
|
|
159
|
-
}
|
|
160
|
-
updateCache([user.id]);
|
|
161
|
-
const _data = data.map(([k, v]) => ({
|
|
162
|
-
k: k === user.id ? STATUS_CONNECTED : v,
|
|
163
|
-
}));
|
|
164
|
-
setData(_data);
|
|
165
|
-
setLoading((prev) => prev.filter((u) => u !== user.id));
|
|
166
|
-
return Promise.resolve(res.data);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}, [data, loading, cache]);
|
|
161
|
+
return handleRequest(user, api_services_1.Endpoints.UserAcceptRequestConnection);
|
|
162
|
+
}, [handleRequest]);
|
|
170
163
|
/**
|
|
171
|
-
* Return current user status if
|
|
164
|
+
* Return current user status if exists,
|
|
172
165
|
* otherwise return null
|
|
173
166
|
*/
|
|
174
|
-
const
|
|
175
|
-
const d = data.filter((
|
|
167
|
+
const getCurrentUserCacheStatus = (0, react_1.useMemo)(() => (user) => {
|
|
168
|
+
const d = data.filter((k) => parseInt(Object.keys(k)[0]) === user.id);
|
|
176
169
|
return d.length ? d[0][user.id] : null;
|
|
177
170
|
}, [data]);
|
|
178
171
|
/**
|
|
@@ -182,40 +175,97 @@ function useSCConnectionsManager(user) {
|
|
|
182
175
|
* @param user
|
|
183
176
|
*/
|
|
184
177
|
const checkUserConnectionStatus = (user) => {
|
|
185
|
-
setLoading(
|
|
186
|
-
api_services_1.http
|
|
178
|
+
setLoading(user.id);
|
|
179
|
+
return api_services_1.http
|
|
187
180
|
.request({
|
|
188
|
-
url: api_services_1.Endpoints.
|
|
189
|
-
method: api_services_1.Endpoints.
|
|
181
|
+
url: api_services_1.Endpoints.UserCheckConnectionStatus.url({ id: user.id }),
|
|
182
|
+
method: api_services_1.Endpoints.UserCheckConnectionStatus.method,
|
|
190
183
|
})
|
|
191
184
|
.then((res) => {
|
|
192
185
|
if (res.status >= 300) {
|
|
193
186
|
return Promise.reject(res);
|
|
194
187
|
}
|
|
188
|
+
setData((prev) => getDataUpdated(prev, user.id, res.data.connection_status));
|
|
195
189
|
updateCache([user.id]);
|
|
196
|
-
|
|
197
|
-
setLoading((prev) => prev.filter((u) => u !== user.id));
|
|
190
|
+
setUnLoading(user.id);
|
|
198
191
|
return Promise.resolve(res.data);
|
|
192
|
+
})
|
|
193
|
+
.catch((e) => {
|
|
194
|
+
setUnLoading(user.id);
|
|
195
|
+
return Promise.reject(e);
|
|
199
196
|
});
|
|
200
197
|
};
|
|
198
|
+
/**
|
|
199
|
+
* Get updated data
|
|
200
|
+
* @param data
|
|
201
|
+
* @param userId
|
|
202
|
+
* @param connectionStatus
|
|
203
|
+
*/
|
|
204
|
+
const getDataUpdated = (data, userId, connectionStatus) => {
|
|
205
|
+
const _index = data.findIndex((k) => parseInt(Object.keys(k)[0]) === userId);
|
|
206
|
+
let _data;
|
|
207
|
+
if (_index < 0) {
|
|
208
|
+
_data = [...data, ...[{ [userId]: connectionStatus }]];
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
_data = data.map((k, i) => {
|
|
212
|
+
if (parseInt(Object.keys(k)[0]) === userId) {
|
|
213
|
+
return { [Object.keys(k)[0]]: connectionStatus };
|
|
214
|
+
}
|
|
215
|
+
return { [Object.keys(k)[0]]: data[i][Object.keys(k)[0]] };
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return _data;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Bypass remote check if the user is followed
|
|
222
|
+
*/
|
|
223
|
+
const getConnectionStatus = (0, react_1.useMemo)(() => (user) => {
|
|
224
|
+
updateCache([user.id]);
|
|
225
|
+
setData((prev) => getDataUpdated(prev, user.id, user.connection_status));
|
|
226
|
+
return user.connection_status;
|
|
227
|
+
}, [data, cache]);
|
|
201
228
|
/**
|
|
202
229
|
* Memoized status
|
|
203
230
|
* If user is already in cache -> check data user statuses,
|
|
204
231
|
* otherwise, check if auth user is connected with user
|
|
205
232
|
*/
|
|
206
|
-
const status = (
|
|
233
|
+
const status = (user) => {
|
|
207
234
|
if (cache.includes(user.id)) {
|
|
208
|
-
return
|
|
235
|
+
return getCurrentUserCacheStatus(user);
|
|
209
236
|
}
|
|
210
|
-
if (
|
|
211
|
-
|
|
237
|
+
if (authUserId) {
|
|
238
|
+
if ('connection_status' in user) {
|
|
239
|
+
return getConnectionStatus(user);
|
|
240
|
+
}
|
|
241
|
+
if (!isLoading(user)) {
|
|
242
|
+
checkUserConnectionStatus(user);
|
|
243
|
+
}
|
|
212
244
|
}
|
|
213
245
|
return null;
|
|
214
|
-
}
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* Empty cache on logout
|
|
249
|
+
*/
|
|
250
|
+
(0, react_1.useEffect)(() => {
|
|
251
|
+
if (!authUserId) {
|
|
252
|
+
emptyCache();
|
|
253
|
+
}
|
|
254
|
+
}, [authUserId]);
|
|
215
255
|
if (connectionsDisabled || !user) {
|
|
216
256
|
return { connections: data, loading, isLoading };
|
|
217
257
|
}
|
|
218
|
-
return {
|
|
258
|
+
return {
|
|
259
|
+
connections: data,
|
|
260
|
+
loading,
|
|
261
|
+
isLoading,
|
|
262
|
+
status,
|
|
263
|
+
requestConnection,
|
|
264
|
+
cancelRequestConnection,
|
|
265
|
+
acceptConnection,
|
|
266
|
+
removeConnection,
|
|
267
|
+
refresh,
|
|
268
|
+
emptyCache,
|
|
269
|
+
};
|
|
219
270
|
}
|
|
220
271
|
exports.default = useSCConnectionsManager;
|
|
221
|
-
//# sourceMappingURL=useSCConnectionsManager.js.map
|
|
@@ -1,33 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
const react_1 = require("react");
|
|
4
|
+
const types_1 = require("@selfcommunity/types");
|
|
27
5
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
28
6
|
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
29
7
|
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
30
|
-
const SCFeatures = __importStar(require("../constants/Features"));
|
|
31
8
|
/**
|
|
32
9
|
:::info
|
|
33
10
|
This custom hook is used to fetch the addressing tag list for the session user
|
|
@@ -59,7 +36,7 @@ function useSCFetchAddressingTagList({ fetch = false }) {
|
|
|
59
36
|
}, []);
|
|
60
37
|
// load addressing tags
|
|
61
38
|
(0, react_1.useEffect)(() => {
|
|
62
|
-
if (!loaded && fetch && scUserContext.user && scPreferences.features.includes(
|
|
39
|
+
if (!loaded && fetch && scUserContext.user && scPreferences.features.includes(types_1.SCFeatureName.TAGGING)) {
|
|
63
40
|
fetchAddressingTags().then((obj) => {
|
|
64
41
|
setLoaded(true);
|
|
65
42
|
setSCAddressingTags(obj);
|
|
@@ -69,4 +46,3 @@ function useSCFetchAddressingTagList({ fetch = false }) {
|
|
|
69
46
|
return { scAddressingTags };
|
|
70
47
|
}
|
|
71
48
|
exports.default = useSCFetchAddressingTagList;
|
|
72
|
-
//# sourceMappingURL=useSCFetchAddressingTagList.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SCBroadcastMessageType } from '@selfcommunity/types';
|
|
2
|
+
import { SCPaginatedResponse } from '@selfcommunity/api-services';
|
|
3
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
4
|
+
/**
|
|
5
|
+
:::info
|
|
6
|
+
This custom hook is used to fetch broadcast messages.
|
|
7
|
+
@param object
|
|
8
|
+
@param object.cacheStrategy
|
|
9
|
+
|
|
10
|
+
:::tipContext can be consumed in this way:
|
|
11
|
+
|
|
12
|
+
```jsx
|
|
13
|
+
const {messages, isLoading} = useSCFetchBroadcastMessages();
|
|
14
|
+
```
|
|
15
|
+
:::
|
|
16
|
+
*/
|
|
17
|
+
declare const useSCFetchBroadcastMessages: (props?: {
|
|
18
|
+
cacheStrategy?: CacheStrategies;
|
|
19
|
+
}) => {
|
|
20
|
+
data: SCPaginatedResponse<SCBroadcastMessageType>;
|
|
21
|
+
loading: boolean;
|
|
22
|
+
fetchMessages: (refresh?: boolean) => Promise<SCPaginatedResponse<SCBroadcastMessageType>>;
|
|
23
|
+
setMessages: (messages: SCBroadcastMessageType[]) => {
|
|
24
|
+
results: SCBroadcastMessageType[];
|
|
25
|
+
next: string;
|
|
26
|
+
count: number;
|
|
27
|
+
previous: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export default useSCFetchBroadcastMessages;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
6
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
7
|
+
const Cache_1 = require("../constants/Cache");
|
|
8
|
+
const Errors_1 = require("../constants/Errors");
|
|
9
|
+
/**
|
|
10
|
+
* Initial base url to fetch the broadcast messages
|
|
11
|
+
*/
|
|
12
|
+
const broadcastMessagesRefreshUrl = `${api_services_1.Endpoints.BroadcastMessagesList.url()}?limit=3`;
|
|
13
|
+
/**
|
|
14
|
+
* Define the key to cache results
|
|
15
|
+
*/
|
|
16
|
+
const broadcastMessagesCacheKey = (0, Cache_1.getBroadcastMessagesObjectCacheKey)();
|
|
17
|
+
/**
|
|
18
|
+
* Initial state
|
|
19
|
+
*/
|
|
20
|
+
const initialData = { results: [], next: broadcastMessagesRefreshUrl, previous: null, count: 0 };
|
|
21
|
+
/**
|
|
22
|
+
:::info
|
|
23
|
+
This custom hook is used to fetch broadcast messages.
|
|
24
|
+
@param object
|
|
25
|
+
@param object.cacheStrategy
|
|
26
|
+
|
|
27
|
+
:::tipContext can be consumed in this way:
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
const {messages, isLoading} = useSCFetchBroadcastMessages();
|
|
31
|
+
```
|
|
32
|
+
:::
|
|
33
|
+
*/
|
|
34
|
+
const useSCFetchBroadcastMessages = (props) => {
|
|
35
|
+
// PROPS
|
|
36
|
+
const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST } = props || {};
|
|
37
|
+
// STATE
|
|
38
|
+
const cachedData = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(broadcastMessagesCacheKey, null) : null;
|
|
39
|
+
const [data, setData] = (0, react_1.useState)(cachedData !== null ? cachedData : initialData);
|
|
40
|
+
const [loading, setLoading] = (0, react_1.useState)(cachedData ? false : null);
|
|
41
|
+
/**
|
|
42
|
+
* Fetch broadcast messages
|
|
43
|
+
* Loads until the messages are already seen
|
|
44
|
+
*/
|
|
45
|
+
const performFetchMessages = (next) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const response = yield api_services_1.http.request({
|
|
47
|
+
url: next,
|
|
48
|
+
method: api_services_1.Endpoints.BroadcastMessagesList.method,
|
|
49
|
+
});
|
|
50
|
+
const data = response.data;
|
|
51
|
+
if (data.next && !data.results[data.results.length - 1]['viewed_at']) {
|
|
52
|
+
const _data = yield performFetchMessages(data.next);
|
|
53
|
+
return { results: data.results.concat(_data.results), next: _data.next, previous: null, count: _data.count };
|
|
54
|
+
}
|
|
55
|
+
return data;
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Fetch broadcast messages
|
|
59
|
+
*/
|
|
60
|
+
const fetchMessages = (refresh = false) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
setLoading(true);
|
|
62
|
+
return performFetchMessages(refresh ? broadcastMessagesRefreshUrl : data.next)
|
|
63
|
+
.then((res) => {
|
|
64
|
+
const _data = refresh ? res : { results: [...data.results, ...res.results], next: res.next, count: res.count, previous: res.previous };
|
|
65
|
+
setData(_data);
|
|
66
|
+
setLoading(false);
|
|
67
|
+
utils_1.LRUCache.set(broadcastMessagesCacheKey, _data);
|
|
68
|
+
return Promise.resolve(res);
|
|
69
|
+
})
|
|
70
|
+
.catch((error) => {
|
|
71
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, error);
|
|
72
|
+
return Promise.reject();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Set broadcast messages
|
|
77
|
+
*/
|
|
78
|
+
const setMessages = (messages) => {
|
|
79
|
+
let _data = {
|
|
80
|
+
results: [...messages],
|
|
81
|
+
next: data.next,
|
|
82
|
+
count: Math.max(data.count - (data.results.length - messages.length), 0),
|
|
83
|
+
previous: data.previous,
|
|
84
|
+
};
|
|
85
|
+
setData(_data);
|
|
86
|
+
utils_1.LRUCache.set(broadcastMessagesCacheKey, _data);
|
|
87
|
+
return _data;
|
|
88
|
+
};
|
|
89
|
+
return { data, loading, fetchMessages, setMessages };
|
|
90
|
+
};
|
|
91
|
+
exports.default = useSCFetchBroadcastMessages;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
12
4
|
const react_1 = require("react");
|
|
13
5
|
const Errors_1 = require("../constants/Errors");
|
|
14
6
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
@@ -54,7 +46,7 @@ const useSCFetchCategories = (props) => {
|
|
|
54
46
|
/**
|
|
55
47
|
* Fetch categories
|
|
56
48
|
*/
|
|
57
|
-
const fetchCategories = (next = api_services_1.Endpoints.CategoryList.url()) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const fetchCategories = (next = api_services_1.Endpoints.CategoryList.url()) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
58
50
|
const response = yield api_services_1.http.request({
|
|
59
51
|
url: next,
|
|
60
52
|
method: api_services_1.Endpoints.CategoryList.method,
|
|
@@ -89,4 +81,3 @@ const useSCFetchCategories = (props) => {
|
|
|
89
81
|
return data;
|
|
90
82
|
};
|
|
91
83
|
exports.default = useSCFetchCategories;
|
|
92
|
-
//# sourceMappingURL=useSCFetchCategories.js.map
|
|
@@ -6,6 +6,7 @@ const api_services_1 = require("@selfcommunity/api-services");
|
|
|
6
6
|
const utils_1 = require("@selfcommunity/utils");
|
|
7
7
|
const Cache_1 = require("../constants/Cache");
|
|
8
8
|
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
9
|
+
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
9
10
|
/**
|
|
10
11
|
:::info
|
|
11
12
|
This custom hook is used to fetch a category object.
|
|
@@ -17,9 +18,13 @@ const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
|
17
18
|
*/
|
|
18
19
|
function useSCFetchCategory({ id = null, category = null, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, }) {
|
|
19
20
|
const __categoryId = category ? category.id : id;
|
|
21
|
+
// CONTEXT
|
|
22
|
+
const scUserContext = (0, SCUserProvider_1.useSCUser)();
|
|
23
|
+
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
20
24
|
// CACHE
|
|
21
25
|
const __categoryCacheKey = (0, Cache_1.getCategoryObjectCacheKey)(__categoryId);
|
|
22
|
-
const
|
|
26
|
+
const __category = authUserId ? category : (0, utils_1.objectWithoutProperties)(category, ['followed']);
|
|
27
|
+
const [scCategory, setSCCategory] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__categoryCacheKey, __category) : null);
|
|
23
28
|
const [error, setError] = (0, react_1.useState)(null);
|
|
24
29
|
/**
|
|
25
30
|
* Memoized fetchTag
|
|
@@ -41,11 +46,12 @@ function useSCFetchCategory({ id = null, category = null, cacheStrategy = utils_
|
|
|
41
46
|
* If id attempt to get the category by id
|
|
42
47
|
*/
|
|
43
48
|
(0, react_1.useEffect)(() => {
|
|
44
|
-
if (__categoryId && (!scCategory || (scCategory && __categoryId !== scCategory.id)
|
|
49
|
+
if (__categoryId && (!scCategory || (scCategory && __categoryId !== scCategory.id))) {
|
|
45
50
|
fetchCategory()
|
|
46
51
|
.then((obj) => {
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
const _c = authUserId ? obj : (0, utils_1.objectWithoutProperties)(obj, ['followed']);
|
|
53
|
+
setSCCategory(_c);
|
|
54
|
+
utils_1.LRUCache.set(__categoryCacheKey, _c);
|
|
49
55
|
})
|
|
50
56
|
.catch((err) => {
|
|
51
57
|
utils_1.LRUCache.delete(__categoryCacheKey);
|
|
@@ -57,16 +63,11 @@ function useSCFetchCategory({ id = null, category = null, cacheStrategy = utils_
|
|
|
57
63
|
}, [__categoryId]);
|
|
58
64
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
59
65
|
if (category) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
setSCCategory(utils_1.LRUCache.get(__categoryCacheKey, category));
|
|
66
|
-
}
|
|
66
|
+
const _c = authUserId ? category : (0, utils_1.objectWithoutProperties)(category, ['followed']);
|
|
67
|
+
setSCCategory(_c);
|
|
68
|
+
utils_1.LRUCache.set(__categoryCacheKey, _c);
|
|
67
69
|
}
|
|
68
70
|
}, [category]);
|
|
69
71
|
return { scCategory, setSCCategory, error };
|
|
70
72
|
}
|
|
71
73
|
exports.default = useSCFetchCategory;
|
|
72
|
-
//# sourceMappingURL=useSCFetchCategory.js.map
|