import {
  HOME, DISCUSSIONS, DIRECT, GET_USER_FEED, GET_USER_COMMENTS, GET_USER_LIKES, GET_SEARCH, GET_BEST_OF, GET_EVERYTHING,
  SIGN_UP, WHO_AM_I, SUBSCRIBE, UNSUBSCRIBE, GET_SUMMARY, GET_USER_SUMMARY,
  UPDATE_USER, UPDATE_USER_PREFERENCES, MEMORIES, GET_USER_MEMORIES,
} from './action-types';


export const request = (type) => `${type}_REQUEST`;
export const response = (type) => `${type}_RESPONSE`;
export const fail = (type) => `${type}_FAIL`;

export const feedGeneratingActions = [HOME, DISCUSSIONS, GET_USER_FEED, GET_USER_COMMENTS, GET_USER_LIKES, DIRECT, GET_SEARCH, GET_BEST_OF, GET_EVERYTHING, GET_SUMMARY, GET_USER_SUMMARY, MEMORIES, GET_USER_MEMORIES];
export const isFeedGeneratingAction = (action) => feedGeneratingActions.includes(action.type);
export const feedRequests = feedGeneratingActions.map(request);
export const feedResponses = feedGeneratingActions.map(response);
export const feedFails = feedGeneratingActions.map(fail);
export const isFeedRequest = (action) => feedRequests.includes(action.type);
export const isFeedResponse = (action) => feedResponses.includes(action.type);
export const isFeedFail = (action) => feedFails.includes(action.type);

export const userChangeActions = [SIGN_UP, WHO_AM_I, SUBSCRIBE, UNSUBSCRIBE, UPDATE_USER, UPDATE_USER_PREFERENCES];
export const userChangeResponses = userChangeActions.map(response);
export const isUserChangeResponse = (action) => userChangeResponses.includes(action.type);

export function requiresAuth(action) {
  return action.apiRequest && !action.nonAuthRequest;
}

export function getFeedName(action) {
  if (action.type === request(HOME) || action.type === HOME) {
    return HOME;
  }
  return `${GET_USER_FEED}_${action.payload.username}`;
}

@@ -668,102 +668,323 @@
 S%5D;%0A
-export const isFeedGeneratingAction = (action) =%3E feedGeneratingActions.includes(action.type);
+const userFeedGeneratingActions = %5BGET_USER_FEED, GET_USER_COMMENTS, GET_USER_LIKES, GET_USER_SUMMARY, GET_USER_MEMORIES%5D;%0A%0Aexport const isFeedGeneratingAction = (action) =%3E feedGeneratingActions.includes(action.type);%0Aconst isUserFeedGeneratingAction = (action) =%3E userFeedGeneratingActions.includes(action.type);%0A
 %0Aexp
@@ -1386,32 +1386,132 @@
 es(action.type);
+%0Aconst isUserFeedRequest = (action) =%3E userFeedGeneratingActions.map(request).includes(action.type);
 %0A%0Aexport const u
@@ -1872,184 +1872,376 @@
 %0A%7D%0A%0A
-export function getFeedName(action) %7B%0A  if (action.type === request(HOME) %7C%7C action.type === HOME) %7B%0A    return HOME;%0A  %7D%0A  return %60$%7BGET_USER_FEED%7D_$%7Baction.payload.username%7D%60
+const unRequest = (type) =%3E type.replace(/_REQUEST$/, '');%0A%0Aexport function getFeedName(action) %7B%0A  if (!isFeedGeneratingAction(action) && !isFeedRequest(action)) %7B%0A    return %22unknown%22;%0A  %7D%0A%0A  if (isUserFeedGeneratingAction(action) %7C%7C isUserFeedRequest(action)) %7B%0A    return %60$%7BunRequest(action.type)%7D_$%7Baction.payload.username%7D%60;%0A  %7D%0A%0A  return unRequest(action.type)
 ;%0A%7D%0A

Update getFeedName function to handle all types of feeds