@selfcommunity/react-core 0.7.0-alpha.1 → 0.7.0-alpha.10
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/SCThemeProvider/index.js +3 -3
- package/lib/cjs/constants/Cache.d.ts +12 -0
- package/lib/cjs/constants/Cache.js +17 -1
- package/lib/cjs/constants/Preferences.d.ts +16 -0
- package/lib/cjs/constants/Preferences.js +31 -2
- package/lib/cjs/constants/Routes.d.ts +6 -0
- package/lib/cjs/constants/Routes.js +14 -1
- package/lib/cjs/hooks/useSCFetchCategory.d.ts +1 -0
- package/lib/cjs/hooks/useSCFetchCategory.js +18 -1
- package/lib/cjs/hooks/useSCFetchCourse.js +15 -15
- package/lib/cjs/hooks/useSCFetchEvent.d.ts +1 -0
- package/lib/cjs/hooks/useSCFetchEvent.js +16 -1
- package/lib/cjs/hooks/useSCFetchGroup.d.ts +1 -0
- package/lib/cjs/hooks/useSCFetchGroup.js +16 -1
- package/lib/cjs/hooks/useSCFetchPaymentOrder.d.ts +20 -0
- package/lib/cjs/hooks/useSCFetchPaymentOrder.js +70 -0
- package/lib/cjs/hooks/useSCFetchPaymentProduct.d.ts +20 -0
- package/lib/cjs/hooks/useSCFetchPaymentProduct.js +70 -0
- package/lib/cjs/hooks/useSCFetchUsers.d.ts +23 -0
- package/lib/cjs/hooks/useSCFetchUsers.js +74 -0
- package/lib/cjs/hooks/useSCJoinedCoursesManager.d.ts +1 -1
- package/lib/cjs/hooks/useSCJoinedCoursesManager.js +36 -67
- package/lib/cjs/hooks/useSCPaymentsEnabled.d.ts +18 -0
- package/lib/cjs/hooks/useSCPaymentsEnabled.js +35 -0
- package/lib/cjs/hooks/useSCPreferenceEnabled.d.ts +6 -0
- package/lib/cjs/hooks/useSCPreferenceEnabled.js +16 -0
- package/lib/cjs/hooks/useSCSubscribedEventsManager.js +4 -14
- package/lib/cjs/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
- package/lib/cjs/hooks/useSCSubscribedGroupsManager.js +29 -54
- package/lib/cjs/hooks/useSCWebPushMessaging.js +2 -2
- package/lib/cjs/index.d.ts +7 -2
- package/lib/cjs/index.js +13 -2
- package/lib/cjs/themes/theme.js +14 -2
- package/lib/cjs/types/theme.d.ts +53 -1
- package/lib/cjs/utils/hooks/index.d.ts +2 -1
- package/lib/cjs/utils/hooks/index.js +3 -1
- package/lib/cjs/utils/hooks/useResizeObserver.d.ts +1 -0
- package/lib/cjs/utils/hooks/useResizeObserver.js +16 -0
- package/lib/cjs/utils/user.d.ts +8 -1
- package/lib/cjs/utils/user.js +15 -2
- package/lib/esm/components/provider/SCThemeProvider/index.js +1 -1
- package/lib/esm/constants/Cache.d.ts +12 -0
- package/lib/esm/constants/Cache.js +12 -0
- package/lib/esm/constants/Preferences.d.ts +16 -0
- package/lib/esm/constants/Preferences.js +28 -0
- package/lib/esm/constants/Routes.d.ts +6 -0
- package/lib/esm/constants/Routes.js +12 -0
- package/lib/esm/hooks/useSCFetchCategory.d.ts +1 -0
- package/lib/esm/hooks/useSCFetchCategory.js +18 -1
- package/lib/esm/hooks/useSCFetchCourse.js +15 -15
- package/lib/esm/hooks/useSCFetchEvent.d.ts +1 -0
- package/lib/esm/hooks/useSCFetchEvent.js +16 -1
- package/lib/esm/hooks/useSCFetchGroup.d.ts +1 -0
- package/lib/esm/hooks/useSCFetchGroup.js +16 -1
- package/lib/esm/hooks/useSCFetchPaymentOrder.d.ts +20 -0
- package/lib/esm/hooks/useSCFetchPaymentOrder.js +67 -0
- package/lib/esm/hooks/useSCFetchPaymentProduct.d.ts +20 -0
- package/lib/esm/hooks/useSCFetchPaymentProduct.js +67 -0
- package/lib/esm/hooks/useSCFetchUsers.d.ts +23 -0
- package/lib/esm/hooks/useSCFetchUsers.js +72 -0
- package/lib/esm/hooks/useSCJoinedCoursesManager.d.ts +1 -1
- package/lib/esm/hooks/useSCJoinedCoursesManager.js +37 -67
- package/lib/esm/hooks/useSCPaymentsEnabled.d.ts +18 -0
- package/lib/esm/hooks/useSCPaymentsEnabled.js +31 -0
- package/lib/esm/hooks/useSCPreferenceEnabled.d.ts +6 -0
- package/lib/esm/hooks/useSCPreferenceEnabled.js +13 -0
- package/lib/esm/hooks/useSCSubscribedEventsManager.js +4 -14
- package/lib/esm/hooks/useSCSubscribedGroupsManager.d.ts +1 -1
- package/lib/esm/hooks/useSCSubscribedGroupsManager.js +29 -54
- package/lib/esm/hooks/useSCWebPushMessaging.js +1 -1
- package/lib/esm/index.d.ts +7 -2
- package/lib/esm/index.js +7 -2
- package/lib/esm/themes/theme.js +13 -1
- package/lib/esm/types/theme.d.ts +53 -1
- package/lib/esm/utils/hooks/index.d.ts +2 -1
- package/lib/esm/utils/hooks/index.js +2 -1
- package/lib/esm/utils/hooks/useResizeObserver.d.ts +1 -0
- package/lib/esm/utils/hooks/useResizeObserver.js +13 -0
- package/lib/esm/utils/user.d.ts +8 -1
- package/lib/esm/utils/user.js +13 -1
- package/lib/umd/440.js +2 -0
- package/lib/umd/react-core.js +1 -1
- package/package.json +6 -6
- package/lib/umd/258.js +0 -2
- /package/lib/umd/{258.js.LICENSE.txt → 440.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
4
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
7
|
+
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
8
|
+
const Cache_1 = require("../constants/Cache");
|
|
9
|
+
const Errors_1 = require("../constants/Errors");
|
|
10
|
+
/**
|
|
11
|
+
:::info
|
|
12
|
+
This custom hook is used to fetch a payment product.
|
|
13
|
+
:::
|
|
14
|
+
* @param object
|
|
15
|
+
* @param object.id
|
|
16
|
+
* @param object.paymentProduct
|
|
17
|
+
* @param object.cacheStrategy
|
|
18
|
+
*/
|
|
19
|
+
function useSCFetchPaymentProduct({ id = null, paymentProduct = null, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, }) {
|
|
20
|
+
const __paymentProductId = (0, react_1.useMemo)(() => (paymentProduct === null || paymentProduct === void 0 ? void 0 : paymentProduct.id) || id, [paymentProduct, id]);
|
|
21
|
+
// CONTEXT
|
|
22
|
+
const scUserContext = (0, SCUserProvider_1.useSCUser)();
|
|
23
|
+
const authUserId = (0, react_1.useMemo)(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) || null; }, [scUserContext.user]);
|
|
24
|
+
// CACHE
|
|
25
|
+
const __paymentProductCacheKey = (0, react_1.useMemo)(() => (0, Cache_1.getPaymentProductObjectCacheKey)(__paymentProductId), [__paymentProductId]);
|
|
26
|
+
const [scPaymentProduct, setScPaymentProduct] = (0, react_1.useState)(cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? utils_1.LRUCache.get(__paymentProductCacheKey, paymentProduct) : null);
|
|
27
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
28
|
+
const setSCPaymentProduct = (0, react_1.useCallback)((c) => {
|
|
29
|
+
setScPaymentProduct(c);
|
|
30
|
+
utils_1.LRUCache.set(__paymentProductCacheKey, c);
|
|
31
|
+
}, [setScPaymentProduct, __paymentProductCacheKey]);
|
|
32
|
+
/**
|
|
33
|
+
* Memoized fetch product
|
|
34
|
+
*/
|
|
35
|
+
const fetchPaymentProduct = (0, react_1.useMemo)(() => (id) => {
|
|
36
|
+
return api_services_1.http
|
|
37
|
+
.request({
|
|
38
|
+
url: api_services_1.Endpoints.GetPaymentProduct.url({ id }),
|
|
39
|
+
method: api_services_1.Endpoints.GetPaymentProduct.method,
|
|
40
|
+
})
|
|
41
|
+
.then((res) => {
|
|
42
|
+
if (res.status >= 300) {
|
|
43
|
+
return Promise.reject(res);
|
|
44
|
+
}
|
|
45
|
+
return Promise.resolve(res.data);
|
|
46
|
+
});
|
|
47
|
+
}, []);
|
|
48
|
+
/**
|
|
49
|
+
* If id attempt to get the course by id
|
|
50
|
+
*/
|
|
51
|
+
(0, react_1.useEffect)(() => {
|
|
52
|
+
if (id !== null && id !== undefined && !paymentProduct) {
|
|
53
|
+
fetchPaymentProduct(id)
|
|
54
|
+
.then((e) => {
|
|
55
|
+
setSCPaymentProduct(e);
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
utils_1.LRUCache.delete(__paymentProductCacheKey);
|
|
59
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}, [id, paymentProduct, authUserId]);
|
|
63
|
+
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
64
|
+
if (paymentProduct) {
|
|
65
|
+
setSCPaymentProduct(paymentProduct);
|
|
66
|
+
}
|
|
67
|
+
}, [paymentProduct, authUserId]);
|
|
68
|
+
return { scPaymentProduct, setSCPaymentProduct, error };
|
|
69
|
+
}
|
|
70
|
+
exports.default = useSCFetchPaymentProduct;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SCUserAutocompleteType } from '@selfcommunity/types';
|
|
2
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
3
|
+
/**
|
|
4
|
+
:::info
|
|
5
|
+
This custom hook is used to fetch users.
|
|
6
|
+
@param object.cacheStrategy
|
|
7
|
+
|
|
8
|
+
:::tip Context can be consumed in this way:
|
|
9
|
+
|
|
10
|
+
```jsx
|
|
11
|
+
const {users, isLoading} = useSCFetchUsers();
|
|
12
|
+
```
|
|
13
|
+
:::
|
|
14
|
+
* @param props
|
|
15
|
+
*/
|
|
16
|
+
declare const useSCFetchUsers: (props?: {
|
|
17
|
+
cacheStrategy?: CacheStrategies;
|
|
18
|
+
search?: string;
|
|
19
|
+
}) => {
|
|
20
|
+
users: SCUserAutocompleteType[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
};
|
|
23
|
+
export default useSCFetchUsers;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const Errors_1 = require("../constants/Errors");
|
|
6
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
7
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
8
|
+
const Cache_1 = require("../constants/Cache");
|
|
9
|
+
// Hydrate cache
|
|
10
|
+
const hydrate = (ids) => {
|
|
11
|
+
if (!ids)
|
|
12
|
+
return null;
|
|
13
|
+
const users = ids.map((id) => {
|
|
14
|
+
const __userCacheKey = (0, Cache_1.getUserObjectCacheKey)(id);
|
|
15
|
+
return utils_1.LRUCache.get(__userCacheKey);
|
|
16
|
+
});
|
|
17
|
+
if (users.filter((u) => !u).length > 0) {
|
|
18
|
+
return null; // revalidate cache
|
|
19
|
+
}
|
|
20
|
+
return users;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
:::info
|
|
24
|
+
This custom hook is used to fetch users.
|
|
25
|
+
@param object.cacheStrategy
|
|
26
|
+
|
|
27
|
+
:::tip Context can be consumed in this way:
|
|
28
|
+
|
|
29
|
+
```jsx
|
|
30
|
+
const {users, isLoading} = useSCFetchUsers();
|
|
31
|
+
```
|
|
32
|
+
:::
|
|
33
|
+
* @param props
|
|
34
|
+
*/
|
|
35
|
+
const useSCFetchUsers = (props) => {
|
|
36
|
+
const { cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, search = '' } = props || {};
|
|
37
|
+
const __usersCacheKey = (0, Cache_1.getUsersObjectCacheKey)(search);
|
|
38
|
+
const cachedUsers = cacheStrategy !== utils_1.CacheStrategies.NETWORK_ONLY ? hydrate(utils_1.LRUCache.get(__usersCacheKey, null)) : null;
|
|
39
|
+
const [data, setData] = (0, react_1.useState)(cachedUsers !== null ? { users: cachedUsers, isLoading: false } : { users: [], isLoading: false });
|
|
40
|
+
const fetchUsers = (next = api_services_1.Endpoints.UserAutocomplete.url(), searchParam) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const response = yield api_services_1.http.request({
|
|
42
|
+
url: next,
|
|
43
|
+
method: api_services_1.Endpoints.UserAutocomplete.method,
|
|
44
|
+
params: searchParam ? { search: searchParam } : undefined,
|
|
45
|
+
});
|
|
46
|
+
const data = response.data;
|
|
47
|
+
if (data.next) {
|
|
48
|
+
return data.results.concat(yield fetchUsers(data.next, searchParam));
|
|
49
|
+
}
|
|
50
|
+
return data.results;
|
|
51
|
+
});
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
if (!search)
|
|
54
|
+
return;
|
|
55
|
+
if (cacheStrategy === utils_1.CacheStrategies.CACHE_FIRST && cachedUsers)
|
|
56
|
+
return;
|
|
57
|
+
fetchUsers(undefined, search)
|
|
58
|
+
.then((data) => {
|
|
59
|
+
setData({ users: data, isLoading: false });
|
|
60
|
+
utils_1.LRUCache.set(__usersCacheKey, data.map((u) => {
|
|
61
|
+
const __userCacheKey = (0, Cache_1.getUserObjectCacheKey)(u.id);
|
|
62
|
+
utils_1.LRUCache.set(__userCacheKey, u);
|
|
63
|
+
return u.id;
|
|
64
|
+
}));
|
|
65
|
+
})
|
|
66
|
+
.catch((error) => {
|
|
67
|
+
console.error(error);
|
|
68
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, 'Unable to retrieve users');
|
|
69
|
+
setData((prev) => (Object.assign(Object.assign({}, prev), { isLoading: false })));
|
|
70
|
+
});
|
|
71
|
+
}, [search]);
|
|
72
|
+
return data;
|
|
73
|
+
};
|
|
74
|
+
exports.default = useSCFetchUsers;
|
|
@@ -30,7 +30,7 @@ export default function useSCJoinedCoursesManager(user?: SCUserType): {
|
|
|
30
30
|
isLoading: (v: number | {
|
|
31
31
|
id: number;
|
|
32
32
|
}) => boolean;
|
|
33
|
-
join: (course: SCCourseType
|
|
33
|
+
join: (course: SCCourseType) => Promise<any>;
|
|
34
34
|
leave: (course: SCCourseType) => Promise<any>;
|
|
35
35
|
joinStatus: (course: SCCourseType) => string;
|
|
36
36
|
refresh: () => void;
|
|
@@ -36,21 +36,15 @@ function useSCJoinedCoursesManager(user) {
|
|
|
36
36
|
Preferences_1.CONFIGURATIONS_COURSES_ENABLED in preferences &&
|
|
37
37
|
preferences[Preferences_1.CONFIGURATIONS_COURSES_ENABLED].value, [preferences, features]);
|
|
38
38
|
const notificationInvitedToJoinCourse = (0, react_1.useRef)(null);
|
|
39
|
-
const notificationRequestedToJoinCourse = (0, react_1.useRef)(null);
|
|
40
|
-
const notificationAcceptedToJoinCourse = (0, react_1.useRef)(null);
|
|
41
39
|
const notificationAddedToCourse = (0, react_1.useRef)(null);
|
|
42
40
|
/**
|
|
43
41
|
* Subscribe to notification types user_follow, user_unfollow
|
|
44
42
|
*/
|
|
45
43
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
46
44
|
notificationInvitedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE}`, notificationSubscriber);
|
|
47
|
-
notificationRequestedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE}`, notificationSubscriber);
|
|
48
|
-
notificationAcceptedToJoinCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE}`, notificationSubscriber);
|
|
49
45
|
notificationAddedToCourse.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_COURSE}`, notificationSubscriber);
|
|
50
46
|
return () => {
|
|
51
47
|
pubsub_js_1.default.unsubscribe(notificationInvitedToJoinCourse.current);
|
|
52
|
-
pubsub_js_1.default.unsubscribe(notificationRequestedToJoinCourse.current);
|
|
53
|
-
pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinCourse.current);
|
|
54
48
|
pubsub_js_1.default.unsubscribe(notificationAddedToCourse.current);
|
|
55
49
|
};
|
|
56
50
|
}, [data]);
|
|
@@ -60,20 +54,20 @@ function useSCJoinedCoursesManager(user) {
|
|
|
60
54
|
* @param dataMsg
|
|
61
55
|
*/
|
|
62
56
|
const notificationSubscriber = (msg, dataMsg) => {
|
|
57
|
+
var _a;
|
|
63
58
|
if (dataMsg.data.course !== undefined) {
|
|
64
59
|
let _status;
|
|
65
60
|
switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
|
|
66
61
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_COURSE:
|
|
67
62
|
_status = types_1.SCCourseJoinStatusType.INVITED;
|
|
68
63
|
break;
|
|
69
|
-
case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_COURSE:
|
|
70
|
-
_status = types_1.SCCourseJoinStatusType.REQUESTED;
|
|
71
|
-
break;
|
|
72
|
-
case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_COURSE:
|
|
73
|
-
_status = types_1.SCCourseJoinStatusType.JOINED;
|
|
74
|
-
break;
|
|
75
64
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_COURSE:
|
|
76
|
-
|
|
65
|
+
if (dataMsg.data.notification_obj.course && ((_a = dataMsg.data.notification_obj.course.paywalls) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
66
|
+
_status = types_1.SCCourseJoinStatusType.PAYMENT_WAITING;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
_status = types_1.SCCourseJoinStatusType.JOINED;
|
|
70
|
+
}
|
|
77
71
|
break;
|
|
78
72
|
}
|
|
79
73
|
updateCache([dataMsg.data.course]);
|
|
@@ -92,8 +86,8 @@ function useSCJoinedCoursesManager(user) {
|
|
|
92
86
|
// Only if user is authenticated
|
|
93
87
|
api_services_1.http
|
|
94
88
|
.request({
|
|
95
|
-
url: api_services_1.Endpoints.
|
|
96
|
-
method: api_services_1.Endpoints.
|
|
89
|
+
url: api_services_1.Endpoints.GetUserJoinedCourses.url({ id: user.id }),
|
|
90
|
+
method: api_services_1.Endpoints.GetUserJoinedCourses.method,
|
|
97
91
|
})
|
|
98
92
|
.then((res) => {
|
|
99
93
|
if (res.status >= 300) {
|
|
@@ -114,67 +108,42 @@ function useSCJoinedCoursesManager(user) {
|
|
|
114
108
|
* Memoized join Course
|
|
115
109
|
* Toggle action
|
|
116
110
|
*/
|
|
117
|
-
const join = (0, react_1.useMemo)(() => (course,
|
|
111
|
+
const join = (0, react_1.useMemo)(() => (course) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
118
112
|
setLoading(course.id);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
.then((res) => {
|
|
127
|
-
if (res.status >= 300) {
|
|
128
|
-
return Promise.reject(res);
|
|
129
|
-
}
|
|
130
|
-
updateCache([course.id]);
|
|
131
|
-
setData((prev) => getDataUpdated(prev, course.id, types_1.SCCourseJoinStatusType.JOINED));
|
|
132
|
-
setUnLoading(course.id);
|
|
133
|
-
return Promise.resolve(res.data);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
return api_services_1.http
|
|
138
|
-
.request({
|
|
139
|
-
url: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.url({ id: course.id }),
|
|
140
|
-
method: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.method,
|
|
141
|
-
})
|
|
142
|
-
.then((res) => {
|
|
143
|
-
if (res.status >= 300) {
|
|
144
|
-
return Promise.reject(res);
|
|
145
|
-
}
|
|
146
|
-
updateCache([course.id]);
|
|
147
|
-
setData((prev) => getDataUpdated(prev, course.id, course.privacy === types_1.SCCoursePrivacyType.PRIVATE && course.join_status !== types_1.SCCourseJoinStatusType.INVITED
|
|
148
|
-
? types_1.SCCourseJoinStatusType.REQUESTED
|
|
149
|
-
: types_1.SCCourseJoinStatusType.JOINED));
|
|
150
|
-
setUnLoading(course.id);
|
|
151
|
-
return Promise.resolve(res.data);
|
|
152
|
-
});
|
|
113
|
+
const res = yield api_services_1.http.request({
|
|
114
|
+
url: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.url({ id: course.id }),
|
|
115
|
+
method: api_services_1.Endpoints.JoinOrAcceptInviteToCourse.method,
|
|
116
|
+
});
|
|
117
|
+
if (res.status >= 300) {
|
|
118
|
+
return Promise.reject(res);
|
|
153
119
|
}
|
|
154
|
-
|
|
120
|
+
updateCache([course.id]);
|
|
121
|
+
setData((prev) => getDataUpdated(prev, course.id, course.privacy === types_1.SCCoursePrivacyType.PRIVATE && course.join_status !== types_1.SCCourseJoinStatusType.INVITED
|
|
122
|
+
? types_1.SCCourseJoinStatusType.REQUESTED
|
|
123
|
+
: types_1.SCCourseJoinStatusType.JOINED));
|
|
124
|
+
setUnLoading(course.id);
|
|
125
|
+
return yield Promise.resolve(res.data);
|
|
126
|
+
}), [data, loading, cache]);
|
|
155
127
|
/**
|
|
156
128
|
* Memoized leave Course
|
|
157
129
|
* Toggle action
|
|
158
130
|
*/
|
|
159
|
-
const leave = (0, react_1.useMemo)(() => (course) => {
|
|
160
|
-
if (course.
|
|
131
|
+
const leave = (0, react_1.useMemo)(() => (course) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
if (data[course.id] !== types_1.SCCourseJoinStatusType.REQUESTED) {
|
|
161
133
|
setLoading(course.id);
|
|
162
|
-
|
|
163
|
-
.request({
|
|
134
|
+
const res = yield api_services_1.http.request({
|
|
164
135
|
url: api_services_1.Endpoints.LeaveOrRemoveCourseRequest.url({ id: course.id }),
|
|
165
136
|
method: api_services_1.Endpoints.LeaveOrRemoveCourseRequest.method,
|
|
166
|
-
})
|
|
167
|
-
.then((res) => {
|
|
168
|
-
if (res.status >= 300) {
|
|
169
|
-
return Promise.reject(res);
|
|
170
|
-
}
|
|
171
|
-
updateCache([course.id]);
|
|
172
|
-
setData((prev) => getDataUpdated(prev, course.id, null));
|
|
173
|
-
setUnLoading(course.id);
|
|
174
|
-
return Promise.resolve(res.data);
|
|
175
137
|
});
|
|
138
|
+
if (res.status >= 300) {
|
|
139
|
+
return Promise.reject(res);
|
|
140
|
+
}
|
|
141
|
+
updateCache([course.id]);
|
|
142
|
+
setData((prev) => getDataUpdated(prev, course.id, null));
|
|
143
|
+
setUnLoading(course.id);
|
|
144
|
+
return yield Promise.resolve(res.data);
|
|
176
145
|
}
|
|
177
|
-
}, [data, loading, cache]);
|
|
146
|
+
}), [data, loading, cache]);
|
|
178
147
|
/**
|
|
179
148
|
* Check the authenticated user subscription status to the course
|
|
180
149
|
* Update the courses cached
|
|
@@ -250,7 +219,7 @@ function useSCJoinedCoursesManager(user) {
|
|
|
250
219
|
if (cache.includes(course.id)) {
|
|
251
220
|
return getCurrentCourseCacheStatus(course);
|
|
252
221
|
}
|
|
253
|
-
if (authUserId) {
|
|
222
|
+
if (authUserId && course) {
|
|
254
223
|
if ('join_status' in course) {
|
|
255
224
|
return getJoinStatus(course);
|
|
256
225
|
}
|
|
@@ -259,7 +228,7 @@ function useSCJoinedCoursesManager(user) {
|
|
|
259
228
|
}
|
|
260
229
|
}
|
|
261
230
|
return null;
|
|
262
|
-
}, [loading, cache, authUserId]);
|
|
231
|
+
}, [loading, cache, authUserId, getJoinStatus, getCurrentCourseCacheStatus]);
|
|
263
232
|
/**
|
|
264
233
|
* Empty cache on logout
|
|
265
234
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
:::info
|
|
3
|
+
This custom hook is used to check if the payments are enabled
|
|
4
|
+
:::
|
|
5
|
+
:::tip How to use it:
|
|
6
|
+
|
|
7
|
+
Follow these steps:
|
|
8
|
+
```jsx
|
|
9
|
+
1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
|
|
10
|
+
2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
|
|
11
|
+
```
|
|
12
|
+
:::
|
|
13
|
+
*/
|
|
14
|
+
export default function useSCPaymentsEnabled(): {
|
|
15
|
+
isPaymentsEnabled: any;
|
|
16
|
+
stripePublicKey: any;
|
|
17
|
+
stripeConnectedAccountId: any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const types_1 = require("@selfcommunity/types");
|
|
6
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
7
|
+
const SCPreferences = tslib_1.__importStar(require("../constants/Preferences"));
|
|
8
|
+
/**
|
|
9
|
+
:::info
|
|
10
|
+
This custom hook is used to check if the payments are enabled
|
|
11
|
+
:::
|
|
12
|
+
:::tip How to use it:
|
|
13
|
+
|
|
14
|
+
Follow these steps:
|
|
15
|
+
```jsx
|
|
16
|
+
1. import useSCPaymentsEnabled from '@selfcommunity/react-core';
|
|
17
|
+
2. const {isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId} = useSCPaymentsEnabled();
|
|
18
|
+
```
|
|
19
|
+
:::
|
|
20
|
+
*/
|
|
21
|
+
function useSCPaymentsEnabled() {
|
|
22
|
+
// CONTEXT
|
|
23
|
+
const { preferences, features } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
24
|
+
const isPaymentsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
25
|
+
features &&
|
|
26
|
+
features.includes(types_1.SCFeatureName.PAYMENTS) &&
|
|
27
|
+
SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED in preferences &&
|
|
28
|
+
preferences[SCPreferences.CONFIGURATIONS_PAYMENTS_ENABLED].value, [preferences]);
|
|
29
|
+
const stripePublicKey = (0, react_1.useMemo)(() => preferences && SCPreferences.STATIC_STRIPE_PUBLIC_KEY in preferences && preferences[SCPreferences.STATIC_STRIPE_PUBLIC_KEY].value, [preferences]);
|
|
30
|
+
const stripeConnectedAccountId = (0, react_1.useMemo)(() => preferences &&
|
|
31
|
+
SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID in preferences &&
|
|
32
|
+
preferences[SCPreferences.CONFIGURATIONS_STRIPE_CONNECTED_ACCOUNT_ID].value, [preferences]);
|
|
33
|
+
return { isPaymentsEnabled, stripePublicKey, stripeConnectedAccountId };
|
|
34
|
+
}
|
|
35
|
+
exports.default = useSCPaymentsEnabled;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom hook to check if a given preference is present and has a value.
|
|
3
|
+
* @param preference - full preference key (e.g., 'section.name')
|
|
4
|
+
* @returns boolean - true if the preference exists and has a value
|
|
5
|
+
*/
|
|
6
|
+
export default function useSCPreferenceEnabled(preference: string): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
const SCPreferencesProvider_1 = require("../components/provider/SCPreferencesProvider");
|
|
5
|
+
/**
|
|
6
|
+
* Custom hook to check if a given preference is present and has a value.
|
|
7
|
+
* @param preference - full preference key (e.g., 'section.name')
|
|
8
|
+
* @returns boolean - true if the preference exists and has a value
|
|
9
|
+
*/
|
|
10
|
+
function useSCPreferenceEnabled(preference) {
|
|
11
|
+
const { preferences } = (0, SCPreferencesProvider_1.useSCPreferences)();
|
|
12
|
+
return (0, react_1.useMemo)(() => {
|
|
13
|
+
return preferences && preference in preferences && preferences[preference].value;
|
|
14
|
+
}, [preferences, preference]);
|
|
15
|
+
}
|
|
16
|
+
exports.default = useSCPreferenceEnabled;
|
|
@@ -37,21 +37,17 @@ function useSCSubscribedEventsManager(user) {
|
|
|
37
37
|
Preferences_1.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
38
38
|
preferences[Preferences_1.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
39
39
|
const notificationInvitedToJoinEvent = (0, react_1.useRef)(null);
|
|
40
|
-
const notificationRequestedToJoinEvent =
|
|
41
|
-
const notificationAcceptedToJoinEvent =
|
|
40
|
+
// const notificationRequestedToJoinEvent = useRef(null);
|
|
41
|
+
// const notificationAcceptedToJoinEvent = useRef(null);
|
|
42
42
|
const notificationAddedToEvent = (0, react_1.useRef)(null);
|
|
43
43
|
/**
|
|
44
44
|
* Subscribe to notification types user_follow, user_unfollow
|
|
45
45
|
*/
|
|
46
46
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
47
47
|
notificationInvitedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT}`, notificationSubscriber);
|
|
48
|
-
notificationRequestedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT}`, notificationSubscriber);
|
|
49
|
-
notificationAcceptedToJoinEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT}`, notificationSubscriber);
|
|
50
48
|
notificationAddedToEvent.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_EVENT}`, notificationSubscriber);
|
|
51
49
|
return () => {
|
|
52
50
|
pubsub_js_1.default.unsubscribe(notificationInvitedToJoinEvent.current);
|
|
53
|
-
pubsub_js_1.default.unsubscribe(notificationRequestedToJoinEvent.current);
|
|
54
|
-
pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinEvent.current);
|
|
55
51
|
pubsub_js_1.default.unsubscribe(notificationAddedToEvent.current);
|
|
56
52
|
};
|
|
57
53
|
}, [data]);
|
|
@@ -67,12 +63,6 @@ function useSCSubscribedEventsManager(user) {
|
|
|
67
63
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_EVENT:
|
|
68
64
|
_status = types_1.SCEventSubscriptionStatusType.INVITED;
|
|
69
65
|
break;
|
|
70
|
-
case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_EVENT:
|
|
71
|
-
_status = types_1.SCEventSubscriptionStatusType.REQUESTED;
|
|
72
|
-
break;
|
|
73
|
-
case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_EVENT:
|
|
74
|
-
_status = types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
75
|
-
break;
|
|
76
66
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_EVENT:
|
|
77
67
|
_status = types_1.SCEventSubscriptionStatusType.SUBSCRIBED;
|
|
78
68
|
break;
|
|
@@ -93,8 +83,8 @@ function useSCSubscribedEventsManager(user) {
|
|
|
93
83
|
// Only if user is authenticated
|
|
94
84
|
api_services_1.http
|
|
95
85
|
.request({
|
|
96
|
-
url: api_services_1.Endpoints.
|
|
97
|
-
method: api_services_1.Endpoints.
|
|
86
|
+
url: api_services_1.Endpoints.GetUserSubscribedEvents.url({ id: user.id }),
|
|
87
|
+
method: api_services_1.Endpoints.GetUserSubscribedEvents.method,
|
|
98
88
|
})
|
|
99
89
|
.then((res) => {
|
|
100
90
|
if (res.status >= 300) {
|
|
@@ -30,7 +30,7 @@ export default function useSCSubscribedGroupsManager(user?: SCUserType): {
|
|
|
30
30
|
isLoading: (v: number | {
|
|
31
31
|
id: number;
|
|
32
32
|
}) => boolean;
|
|
33
|
-
subscribe: (group: SCGroupType
|
|
33
|
+
subscribe: (group: SCGroupType) => Promise<any>;
|
|
34
34
|
unsubscribe: (group: SCGroupType) => Promise<any>;
|
|
35
35
|
subscriptionStatus: (group: SCGroupType) => string;
|
|
36
36
|
refresh: () => void;
|
|
@@ -37,21 +37,15 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
37
37
|
Preferences_1.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
38
38
|
preferences[Preferences_1.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
39
39
|
const notificationInvitedToJoinGroup = (0, react_1.useRef)(null);
|
|
40
|
-
const notificationRequestedToJoinGroup = (0, react_1.useRef)(null);
|
|
41
|
-
const notificationAcceptedToJoinGroup = (0, react_1.useRef)(null);
|
|
42
40
|
const notificationAddedToGroup = (0, react_1.useRef)(null);
|
|
43
41
|
/**
|
|
44
42
|
* Subscribe to notification types user_follow, user_unfollow
|
|
45
43
|
*/
|
|
46
44
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
47
45
|
notificationInvitedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP}`, notificationSubscriber);
|
|
48
|
-
notificationRequestedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP}`, notificationSubscriber);
|
|
49
|
-
notificationAcceptedToJoinGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP}`, notificationSubscriber);
|
|
50
46
|
notificationAddedToGroup.current = pubsub_js_1.default.subscribe(`${types_1.SCNotificationTopicType.INTERACTION}.${types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP}`, notificationSubscriber);
|
|
51
47
|
return () => {
|
|
52
48
|
pubsub_js_1.default.unsubscribe(notificationInvitedToJoinGroup.current);
|
|
53
|
-
pubsub_js_1.default.unsubscribe(notificationRequestedToJoinGroup.current);
|
|
54
|
-
pubsub_js_1.default.unsubscribe(notificationAcceptedToJoinGroup.current);
|
|
55
49
|
pubsub_js_1.default.unsubscribe(notificationAddedToGroup.current);
|
|
56
50
|
};
|
|
57
51
|
}, [data]);
|
|
@@ -61,20 +55,20 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
61
55
|
* @param dataMsg
|
|
62
56
|
*/
|
|
63
57
|
const notificationSubscriber = (msg, dataMsg) => {
|
|
58
|
+
var _a;
|
|
64
59
|
if (dataMsg.data.group !== undefined) {
|
|
65
60
|
let _status;
|
|
66
61
|
switch (Notification_1.SCNotificationMapping[dataMsg.data.activity_type]) {
|
|
67
62
|
case types_1.SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP:
|
|
68
63
|
_status = types_1.SCGroupSubscriptionStatusType.INVITED;
|
|
69
64
|
break;
|
|
70
|
-
case types_1.SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP:
|
|
71
|
-
_status = types_1.SCGroupSubscriptionStatusType.REQUESTED;
|
|
72
|
-
break;
|
|
73
|
-
case types_1.SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP:
|
|
74
|
-
_status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
|
|
75
|
-
break;
|
|
76
65
|
case types_1.SCNotificationTypologyType.USER_ADDED_TO_GROUP:
|
|
77
|
-
|
|
66
|
+
if (dataMsg.data.notification_obj.group && ((_a = dataMsg.data.notification_obj.group.paywalls) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
67
|
+
_status = types_1.SCGroupSubscriptionStatusType.PAYMENT_WAITING;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
_status = types_1.SCGroupSubscriptionStatusType.SUBSCRIBED;
|
|
71
|
+
}
|
|
78
72
|
break;
|
|
79
73
|
}
|
|
80
74
|
updateCache([dataMsg.data.group]);
|
|
@@ -93,8 +87,8 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
93
87
|
// Only if user is authenticated
|
|
94
88
|
api_services_1.http
|
|
95
89
|
.request({
|
|
96
|
-
url: api_services_1.Endpoints.
|
|
97
|
-
method: api_services_1.Endpoints.
|
|
90
|
+
url: api_services_1.Endpoints.GetUserSubscribedGroups.url({ id: user.id }),
|
|
91
|
+
method: api_services_1.Endpoints.GetUserSubscribedGroups.method,
|
|
98
92
|
})
|
|
99
93
|
.then((res) => {
|
|
100
94
|
if (res.status >= 300) {
|
|
@@ -115,50 +109,31 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
115
109
|
* Memoized subscribe Group
|
|
116
110
|
* Toggle action
|
|
117
111
|
*/
|
|
118
|
-
const subscribe = (0, react_1.useMemo)(() => (group
|
|
112
|
+
const subscribe = (0, react_1.useMemo)(() => (group) => {
|
|
119
113
|
setLoading(group.id);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
return api_services_1.http
|
|
139
|
-
.request({
|
|
140
|
-
url: api_services_1.Endpoints.SubscribeToGroup.url({ id: group.id }),
|
|
141
|
-
method: api_services_1.Endpoints.SubscribeToGroup.method,
|
|
142
|
-
})
|
|
143
|
-
.then((res) => {
|
|
144
|
-
if (res.status >= 300) {
|
|
145
|
-
return Promise.reject(res);
|
|
146
|
-
}
|
|
147
|
-
updateCache([group.id]);
|
|
148
|
-
setData((prev) => getDataUpdated(prev, group.id, group.privacy === types_1.SCGroupPrivacyType.PRIVATE && group.subscription_status !== types_1.SCGroupSubscriptionStatusType.INVITED
|
|
149
|
-
? types_1.SCGroupSubscriptionStatusType.REQUESTED
|
|
150
|
-
: types_1.SCGroupSubscriptionStatusType.SUBSCRIBED));
|
|
151
|
-
setUnLoading(group.id);
|
|
152
|
-
return Promise.resolve(res.data);
|
|
153
|
-
});
|
|
154
|
-
}
|
|
114
|
+
return api_services_1.http
|
|
115
|
+
.request({
|
|
116
|
+
url: api_services_1.Endpoints.SubscribeToGroup.url({ id: group.id }),
|
|
117
|
+
method: api_services_1.Endpoints.SubscribeToGroup.method,
|
|
118
|
+
})
|
|
119
|
+
.then((res) => {
|
|
120
|
+
if (res.status >= 300) {
|
|
121
|
+
return Promise.reject(res);
|
|
122
|
+
}
|
|
123
|
+
updateCache([group.id]);
|
|
124
|
+
setData((prev) => getDataUpdated(prev, group.id, group.privacy === types_1.SCGroupPrivacyType.PRIVATE && group.subscription_status !== types_1.SCGroupSubscriptionStatusType.INVITED
|
|
125
|
+
? types_1.SCGroupSubscriptionStatusType.REQUESTED
|
|
126
|
+
: types_1.SCGroupSubscriptionStatusType.SUBSCRIBED));
|
|
127
|
+
setUnLoading(group.id);
|
|
128
|
+
return Promise.resolve(res.data);
|
|
129
|
+
});
|
|
155
130
|
}, [data, loading, cache]);
|
|
156
131
|
/**
|
|
157
132
|
* Memoized subscribe Group
|
|
158
133
|
* Toggle action
|
|
159
134
|
*/
|
|
160
135
|
const unsubscribe = (0, react_1.useMemo)(() => (group) => {
|
|
161
|
-
if (group.
|
|
136
|
+
if (data[group.id] !== types_1.SCGroupSubscriptionStatusType.REQUESTED) {
|
|
162
137
|
setLoading(group.id);
|
|
163
138
|
return api_services_1.http
|
|
164
139
|
.request({
|
|
@@ -251,7 +226,7 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
251
226
|
if (cache.includes(group.id)) {
|
|
252
227
|
return getCurrentGroupCacheStatus(group);
|
|
253
228
|
}
|
|
254
|
-
if (authUserId) {
|
|
229
|
+
if (authUserId && group) {
|
|
255
230
|
if ('subscription_status' in group) {
|
|
256
231
|
return getSubscriptionStatus(group);
|
|
257
232
|
}
|
|
@@ -260,7 +235,7 @@ function useSCSubscribedGroupsManager(user) {
|
|
|
260
235
|
}
|
|
261
236
|
}
|
|
262
237
|
return null;
|
|
263
|
-
}, [loading, cache, authUserId]);
|
|
238
|
+
}, [loading, cache, authUserId, getSubscriptionStatus, getCurrentGroupCacheStatus]);
|
|
264
239
|
/**
|
|
265
240
|
* Empty cache on logout
|
|
266
241
|
*/
|
|
@@ -7,7 +7,7 @@ const react_1 = require("react");
|
|
|
7
7
|
const SCContextProvider_1 = require("../components/provider/SCContextProvider");
|
|
8
8
|
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
9
9
|
const utils_1 = require("@selfcommunity/utils");
|
|
10
|
-
const
|
|
10
|
+
const material_1 = require("@mui/material");
|
|
11
11
|
const utils_2 = require("@selfcommunity/utils");
|
|
12
12
|
const Errors_1 = require("../constants/Errors");
|
|
13
13
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
@@ -61,7 +61,7 @@ function useSCWebPushMessaging() {
|
|
|
61
61
|
const showCustomRequestNotificationSnackbar = () => {
|
|
62
62
|
if (!js_cookie_1.default.get(Notifications_1.NOTIFICATIONS_WEB_PUSH_MESSAGING_DIALOG_COOKIE)) {
|
|
63
63
|
enqueueSnackbar(intl.formatMessage({ id: 'ui.webPushNotification.requestPermission', defaultMessage: 'ui.webPushNotification.requestPermission' }), {
|
|
64
|
-
action: (snackbarId) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(
|
|
64
|
+
action: (snackbarId) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", sx: { color: '#FFF' }, onClick: () => requestNotificationPermission(snackbarId) }, { children: intl.formatMessage({ id: 'ui.webPushNotification.allow', defaultMessage: 'ui.webPushNotification.allow' }) })), (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", sx: { color: '#FFF' }, onClick: () => closeRequestNotificationSnackbar(snackbarId) }, { children: intl.formatMessage({ id: 'ui.webPushNotification.block', defaultMessage: 'ui.webPushNotification.block' }) }))] })),
|
|
65
65
|
variant: 'default',
|
|
66
66
|
anchorOrigin: { horizontal: 'center', vertical: 'bottom' },
|
|
67
67
|
preventDuplicate: true,
|