@selfcommunity/react-core 0.6.0-alpha.4 → 0.6.0-alpha.6
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const Errors_1 = require("../constants/Errors");
|
|
5
|
-
const types_1 = require("@selfcommunity/types");
|
|
6
3
|
const api_services_1 = require("@selfcommunity/api-services");
|
|
4
|
+
const types_1 = require("@selfcommunity/types");
|
|
7
5
|
const utils_1 = require("@selfcommunity/utils");
|
|
8
|
-
const
|
|
6
|
+
const react_1 = require("react");
|
|
9
7
|
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
10
8
|
const SCUserProvider_1 = require("../components/provider/SCUserProvider");
|
|
9
|
+
const Cache_1 = require("../constants/Cache");
|
|
10
|
+
const Errors_1 = require("../constants/Errors");
|
|
11
11
|
/**
|
|
12
12
|
:::info
|
|
13
13
|
This custom hook is used to fetch an event object.
|
|
@@ -57,10 +57,10 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
57
57
|
/**
|
|
58
58
|
* Memoized fetchTag
|
|
59
59
|
*/
|
|
60
|
-
const fetchEvent = (0, react_1.useMemo)(() => () => {
|
|
60
|
+
const fetchEvent = (0, react_1.useMemo)(() => (id) => {
|
|
61
61
|
return api_services_1.http
|
|
62
62
|
.request({
|
|
63
|
-
url: api_services_1.Endpoints.GetEventInfo.url({ id
|
|
63
|
+
url: api_services_1.Endpoints.GetEventInfo.url({ id }),
|
|
64
64
|
method: api_services_1.Endpoints.GetEventInfo.method,
|
|
65
65
|
})
|
|
66
66
|
.then((res) => {
|
|
@@ -69,13 +69,13 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
69
69
|
}
|
|
70
70
|
return Promise.resolve(res.data);
|
|
71
71
|
});
|
|
72
|
-
}, [
|
|
72
|
+
}, []);
|
|
73
73
|
/**
|
|
74
74
|
* If id attempt to get the event by id
|
|
75
75
|
*/
|
|
76
76
|
(0, react_1.useEffect)(() => {
|
|
77
|
-
if (
|
|
78
|
-
fetchEvent()
|
|
77
|
+
if (id !== null && id !== undefined && !event) {
|
|
78
|
+
fetchEvent(id)
|
|
79
79
|
.then((e) => {
|
|
80
80
|
setSCEvent(e);
|
|
81
81
|
})
|
|
@@ -86,7 +86,7 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
|
|
|
86
86
|
utils_1.Logger.error(Errors_1.SCOPE_SC_CORE, err.message);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
}, [
|
|
89
|
+
}, [id, event, authUserId]);
|
|
90
90
|
(0, use_deep_compare_effect_1.useDeepCompareEffectNoCheck)(() => {
|
|
91
91
|
if (event) {
|
|
92
92
|
setSCEvent(event);
|
|
@@ -169,7 +169,6 @@ const validateWebSocket = (v) => {
|
|
|
169
169
|
.filter((key) => _options.includes(key))
|
|
170
170
|
.reduce((obj, key) => {
|
|
171
171
|
const res = exports.notificationsWebSocketOptions[key].validator(v[key], v);
|
|
172
|
-
console.log(key, v, res);
|
|
173
172
|
res.errors.map((error) => errors.push(error));
|
|
174
173
|
res.warnings.map((warning) => warnings.push(warning));
|
|
175
174
|
obj[key] = res.value;
|
|
@@ -680,7 +679,6 @@ exports.validateOpenAI = validateOpenAI;
|
|
|
680
679
|
* @param v
|
|
681
680
|
*/
|
|
682
681
|
const validateGeocoding = (v) => {
|
|
683
|
-
//console.log(v);
|
|
684
682
|
const errors = [];
|
|
685
683
|
const warnings = [];
|
|
686
684
|
if (v && !(0, utils_1.isObject)(v)) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
3
|
-
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
4
1
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
2
|
+
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
5
3
|
import { CacheStrategies, Logger, LRUCache, objectWithoutProperties } from '@selfcommunity/utils';
|
|
6
|
-
import {
|
|
4
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
5
|
import { useDeepCompareEffectNoCheck } from 'use-deep-compare-effect';
|
|
8
6
|
import { useSCUser } from '../components/provider/SCUserProvider';
|
|
7
|
+
import { getEventObjectCacheKey } from '../constants/Cache';
|
|
8
|
+
import { SCOPE_SC_CORE } from '../constants/Errors';
|
|
9
9
|
/**
|
|
10
10
|
:::info
|
|
11
11
|
This custom hook is used to fetch an event object.
|
|
@@ -55,10 +55,10 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
55
55
|
/**
|
|
56
56
|
* Memoized fetchTag
|
|
57
57
|
*/
|
|
58
|
-
const fetchEvent = useMemo(() => () => {
|
|
58
|
+
const fetchEvent = useMemo(() => (id) => {
|
|
59
59
|
return http
|
|
60
60
|
.request({
|
|
61
|
-
url: Endpoints.GetEventInfo.url({ id
|
|
61
|
+
url: Endpoints.GetEventInfo.url({ id }),
|
|
62
62
|
method: Endpoints.GetEventInfo.method,
|
|
63
63
|
})
|
|
64
64
|
.then((res) => {
|
|
@@ -67,13 +67,13 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
67
67
|
}
|
|
68
68
|
return Promise.resolve(res.data);
|
|
69
69
|
});
|
|
70
|
-
}, [
|
|
70
|
+
}, []);
|
|
71
71
|
/**
|
|
72
72
|
* If id attempt to get the event by id
|
|
73
73
|
*/
|
|
74
74
|
useEffect(() => {
|
|
75
|
-
if (
|
|
76
|
-
fetchEvent()
|
|
75
|
+
if (id !== null && id !== undefined && !event) {
|
|
76
|
+
fetchEvent(id)
|
|
77
77
|
.then((e) => {
|
|
78
78
|
setSCEvent(e);
|
|
79
79
|
})
|
|
@@ -84,7 +84,7 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
|
|
|
84
84
|
Logger.error(SCOPE_SC_CORE, err.message);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
}, [
|
|
87
|
+
}, [id, event, authUserId]);
|
|
88
88
|
useDeepCompareEffectNoCheck(() => {
|
|
89
89
|
if (event) {
|
|
90
90
|
setSCEvent(event);
|
|
@@ -158,7 +158,6 @@ export const validateWebSocket = (v) => {
|
|
|
158
158
|
.filter((key) => _options.includes(key))
|
|
159
159
|
.reduce((obj, key) => {
|
|
160
160
|
const res = notificationsWebSocketOptions[key].validator(v[key], v);
|
|
161
|
-
console.log(key, v, res);
|
|
162
161
|
res.errors.map((error) => errors.push(error));
|
|
163
162
|
res.warnings.map((warning) => warnings.push(warning));
|
|
164
163
|
obj[key] = res.value;
|
|
@@ -645,7 +644,6 @@ export const validateOpenAI = (v) => {
|
|
|
645
644
|
* @param v
|
|
646
645
|
*/
|
|
647
646
|
export const validateGeocoding = (v) => {
|
|
648
|
-
//console.log(v);
|
|
649
647
|
const errors = [];
|
|
650
648
|
const warnings = [];
|
|
651
649
|
if (v && !isObject(v)) {
|