@selfcommunity/react-core 0.6.0-alpha.2 → 0.6.0-alpha.3

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.
@@ -19,7 +19,6 @@ const SCUserProvider_1 = require("../components/provider/SCUserProvider");
19
19
  * @param object.cacheStrategy
20
20
  */
21
21
  function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, }) {
22
- console.log('Params: ', event, id);
23
22
  const __eventId = event ? event.id : id;
24
23
  // CONTEXT
25
24
  const scUserContext = (0, SCUserProvider_1.useSCUser)();
@@ -37,9 +36,14 @@ function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheS
37
36
  authUserId !== null &&
38
37
  ((e.privacy === types_1.SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === types_1.SCEventSubscriptionStatusType.INVITED)) {
39
38
  // Auto subscribe to the event
40
- api_services_1.EventService.subscribeToEvent(e.id).then(() => {
39
+ api_services_1.EventService.subscribeToEvent(e.id)
40
+ .then(() => {
41
41
  const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: types_1.SCEventSubscriptionStatusType.SUBSCRIBED });
42
- console.log('Update event', updatedEvent.id);
42
+ setScEvent(updatedEvent);
43
+ utils_1.LRUCache.set(__eventCacheKey, updatedEvent);
44
+ })
45
+ .catch(() => {
46
+ const updatedEvent = authUserId ? e : (0, utils_1.objectWithoutProperties)(e, ['subscription_status']);
43
47
  setScEvent(updatedEvent);
44
48
  utils_1.LRUCache.set(__eventCacheKey, updatedEvent);
45
49
  });
@@ -17,7 +17,6 @@ import { useSCUser } from '../components/provider/SCUserProvider';
17
17
  * @param object.cacheStrategy
18
18
  */
19
19
  export default function useSCFetchEvent({ id = null, event = null, autoSubscribe = true, cacheStrategy = CacheStrategies.CACHE_FIRST, }) {
20
- console.log('Params: ', event, id);
21
20
  const __eventId = event ? event.id : id;
22
21
  // CONTEXT
23
22
  const scUserContext = useSCUser();
@@ -35,9 +34,14 @@ export default function useSCFetchEvent({ id = null, event = null, autoSubscribe
35
34
  authUserId !== null &&
36
35
  ((e.privacy === SCEventPrivacyType.PUBLIC && !e.subscription_status) || e.subscription_status === SCEventSubscriptionStatusType.INVITED)) {
37
36
  // Auto subscribe to the event
38
- EventService.subscribeToEvent(e.id).then(() => {
37
+ EventService.subscribeToEvent(e.id)
38
+ .then(() => {
39
39
  const updatedEvent = Object.assign(Object.assign({}, e), { subscription_status: SCEventSubscriptionStatusType.SUBSCRIBED });
40
- console.log('Update event', updatedEvent.id);
40
+ setScEvent(updatedEvent);
41
+ LRUCache.set(__eventCacheKey, updatedEvent);
42
+ })
43
+ .catch(() => {
44
+ const updatedEvent = authUserId ? e : objectWithoutProperties(e, ['subscription_status']);
41
45
  setScEvent(updatedEvent);
42
46
  LRUCache.set(__eventCacheKey, updatedEvent);
43
47
  });