summaryrefslogtreecommitdiffstats
path: root/src/app/contextHandler
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/contextHandler')
-rw-r--r--src/app/contextHandler/ContextHandlerActions.js40
-rw-r--r--src/app/contextHandler/ContextHandlerConstants.js2
2 files changed, 21 insertions, 21 deletions
diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js
index 889020a..0fe43ff 100644
--- a/src/app/contextHandler/ContextHandlerActions.js
+++ b/src/app/contextHandler/ContextHandlerActions.js
@@ -65,17 +65,22 @@ function getExternalParamValues(urlParams) {
}
function createSubscriptionPayloadEvent(payload) {
- return {
- type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND,
- data: payload
- };
-}
-function createSubscriptionIsEmptyEvent() {
- return {
- type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY,
- data: {}
- };
+ let event = undefined;
+
+ if (payload.subscriptionEnabled) {
+ event = {
+ type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND,
+ data: payload
+ };
+ } else {
+ event = {
+ type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY,
+ data: {}
+ };
+ }
+
+ return event;
}
function fetchSubscriptionPayload(fetchRequestCallback) {
@@ -86,26 +91,21 @@ function fetchSubscriptionPayload(fetchRequestCallback) {
return Promise.reject(new Error(response.status));
} else {
// assume 200 status
- return response;
+ return response.json();
}
}
).then(
(results)=> {
dispatch(createSubscriptionPayloadEvent(results));
-
}
).catch(
- (e) => {
- if(e.name === 'EmptyResponseException'){
- dispatch(getClearGlobalMessageEvent());
- dispatch(createSubscriptionIsEmptyEvent());
- } else{
- dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING));
- }
+ () => {
+ dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING));
}
);
};
}
+
export function getSubscriptionPayload() {
let externalfetchRequest =
() => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET);
@@ -113,6 +113,7 @@ export function getSubscriptionPayload() {
dispatch(fetchSubscriptionPayload(externalfetchRequest));
};
}
+
function validateExternalParams(externalURLParams) {
if(externalURLParams.view && externalURLParams.entityId && externalURLParams.entityType) {
return true;
@@ -121,7 +122,6 @@ function validateExternalParams(externalURLParams) {
}
-
function createSuggestionFoundEvent(suggestion) {
return {
type: contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND,
diff --git a/src/app/contextHandler/ContextHandlerConstants.js b/src/app/contextHandler/ContextHandlerConstants.js
index 6229968..9abbb31 100644
--- a/src/app/contextHandler/ContextHandlerConstants.js
+++ b/src/app/contextHandler/ContextHandlerConstants.js
@@ -39,7 +39,7 @@ export const FAILED_REQUEST = 'Failed to pull result for the request.';
export const ZERO_RESULT = 'No result has been found for this request.';
export const MULTIPLE_RESULT = 'Multiple results were found for this request so none got selected.';
export const SUBSCRIPTION_FAILED_MESSAGE = 'Failed to fetch subscription payload.';
-export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/subscription/getsubscription';
+export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/rest/subscription/getsubscription';