export default createReducer()

in src/reducers/app-reducer.ts [65:384]


export default createReducer(initialState, {
  [types.INITIALIZE_AUTH](
    state: RootState,
    action: {
      auth: Auth;
    },
  ) {
    const {auth} = action;
    return {...state, auth};
  },

  [types.SET_PERMISSIONS](
    state: RootState,
    action: {
      permissionsStore: PermissionsStore;
      currentUser: User;
    },
  ) {
    const {permissionsStore, currentUser} = action;
    return {
      ...state,
      issuePermissions: new IssuePermissions(permissionsStore, currentUser),
    };
  },

  [types.LOG_OUT](state: RootState, action: Record<string, any> = {}) {
    return {...state, auth: null};
  },

  [types.OPEN_MENU](state: RootState) {
    return {...state, showMenu: true};
  },

  [types.CLOSE_MENU](state: RootState) {
    return {...state, showMenu: false};
  },

  [types.OPEN_DEBUG_VIEW](state: RootState) {
    return {...state, showDebugView: true};
  },

  [types.CLOSE_DEBUG_VIEW](state: RootState) {
    return {...state, showDebugView: false};
  },

  [types.SET_FEATURES](
    state: RootState,
    action: {
      features: EndUserAgreement;
    },
  ) {
    return {...state, features: action.features};
  },

  [types.SHOW_USER_AGREEMENT](
    state: RootState,
    action: {
      agreement: EndUserAgreement;
    },
  ) {
    return {
      ...state,
      showUserAgreement: true,
      endUserAgreement: action.agreement,
    };
  },

  [types.HIDE_USER_AGREEMENT](state: RootState) {
    return {...state, showUserAgreement: false, endUserAgreement: null};
  },

  [types.RECEIVE_OTHER_ACCOUNTS](
    state: RootState,
    action: {
      otherAccounts: StorageState[];
    },
  ) {
    return {...state, otherAccounts: action.otherAccounts};
  },

  [types.BEGIN_ACCOUNT_CHANGE](
    state: RootState,
    action: {
      otherAccounts: StorageState[];
    },
  ) {
    return {...state, isChangingAccount: true};
  },

  [types.END_ACCOUNT_CHANGE](
    state: RootState,
    action: {
      otherAccounts: StorageState[];
    },
  ) {
    return {...state, isChangingAccount: false};
  },

  [types.RECEIVE_WORK_TIME_SETTINGS](
    state: RootState,
    action: {
      workTimeSettings: WorkTimeSettings;
    },
  ) {
    return {...state, workTimeSettings: action.workTimeSettings};
  },

  [types.RECEIVE_USER](
    state: RootState,
    action: {
      user: User;
    },
  ) {
    return {
      ...state,
      ...{
        user: action.user,
      },
    };
  },

  [types.RECEIVE_USER_APPEARANCE_PROFILE](
    state: RootState,
    action: {
      appearance: UserAppearanceProfile;
    },
  ) {
    const {user} = state;

    const _user = user || {
      profiles: {},
    };

    const updatedProfiles = Object.assign({}, _user.profiles || {}, {
      appearance: action.appearance,
    });
    const updatedUser = {
      ...state.user,
      ...{
        profiles: updatedProfiles,
      },
    };
    return {
      ...state,
      ...{
        user: updatedUser,
      },
    };
  },
  [types.RECEIVE_USER_HELPDESK_PROFILES](
    state: RootState,
    action: { helpdesk: UserHelpdeskProfile;},
  ) {
    const {user} = state;

    const _user = user || {
      profiles: {},
    };

    const updatedProfiles = Object.assign({}, _user.profiles || {}, {
      helpdesk: action.helpdesk,
    });
    const updatedUser = {
      ...state.user,
      profiles: updatedProfiles,
    };
    return {
      ...state,
      ...{
        user: updatedUser,
      },
    };
  },

  [types.RECEIVE_USER_ARTICLES_PROFILE](
    state: RootState,
    action: {
      articles: UserArticlesProfile;
    },
  ) {
    const {user} = state;

    const _user = user || {
      profiles: {},
    };

    const updatedProfiles = Object.assign({}, _user.profiles || {}, {
      articles: action.articles,
    });
    const updatedUser = {
      ...state.user,
      ...{
        profiles: updatedProfiles,
      },
    };
    return {
      ...state,
      ...{
        user: updatedUser,
      },
    };
  },

  [types.SET_NETWORK](
    state: RootState,
    action: {
      networkState: NetInfoState;
    },
  ) {
    return {...state, networkState: action.networkState};
  },

  [types.INBOX_THREADS_FOLDERS](
    state: RootState,
    action: {
      inboxThreadsFolders: InboxFolder[];
    },
  ) {
    const map: Record<string, InboxFolder> = state.inboxThreadsFolders.reduce(
      (mf: Record<string, InboxFolder>, it: InboxFolder) => ({
        ...mf,
        [it.id]: it,
      }),
      {},
    );
    return {
      ...state,
      inboxThreadsFolders: action.inboxThreadsFolders.map((it: InboxFolder) => {
        const me = map[it.id];
        return {
          ...it,
          lastSeen: Math.max(
            it.lastSeen,
            typeof me?.lastSeen === 'number' ? me.lastSeen : -1,
          ),
          lastNotified: Math.max(
            it.lastNotified,
            typeof me?.lastNotified === 'number' ? me.lastNotified : -1,
          ),
        };
      }),
    };
  },

  [types.INBOX_THREADS_FOLDER_SEEN](
    state: RootState,
    action: {
      folderId: string;
      lasSeen: number;
    },
  ) {
    return {
      ...state,
      inboxThreadsFolders: state.inboxThreadsFolders.reduce(
        (list: InboxFolder[], it: InboxFolder) => {
          return list.concat(
            !action.folderId || it.id === action.folderId
              ? {...it, lastSeen: Math.max(action.lastSeen, it.lastSeen)}
              : it,
          );
        },
        [],
      ),
    };
  },

  [types.SET_PROGRESS](
    state: RootState,
    action: {
      isInProgress: boolean;
    },
  ) {
    return {...state, isInProgress: action.isInProgress};
  },

  [types.SET_DRAFT_COMMENT_DATA](
    state: RootState,
    action: DraftCommentData,
  ) {
    const {setDraft, getCommentDraft, entity} = action;
    return {
      ...state,
      draftCommentData: {
        entity,
        getCommentDraft,
        setDraft,
      },
    };
  },

  [types.SET_SETTINGS](
    state: RootState,
    action: { globalSettings: GlobalSettings },
  ) {
    return {
      ...state,
      globalSettings: action.globalSettings,
    };
  },

  [types.SET_HELPDESK_MENU_HIDDEN](
    state: RootState,
    action: { hidden: boolean },
  ) {
    return {
      ...state,
      helpdeskMenuHidden: action.hidden,
    };
  },

  [types.SET_PROJECTS](
    state: RootState,
    action: { projects: UserProject[] },
  ) {
    return {
      ...state,
      projects: action.projects,
    };
  },
});