const actionTypes = [
  'INIT',
  'USER_ALERT',
  'SCREEN_UPDATED',

  'BACKGROUND_TASK_START',
  'BACKGROUND_TASK_PROGRESS',
  'BACKGROUND_TASK_ERROR',
  'BACKGROUND_TASK_STOP',

  'CHECK_FOR_UPDATES_START',
  'CHECK_FOR_UPDATES_RESULT',
  'CHECK_FOR_UPDATES_ERROR',

  'LOAD_SCRIPT_START',
  'LOAD_SCRIPT_RESULT',
  'LOAD_SCRIPT_ERROR',

  'PAY_START',
  'PAY_PROGRESS',
  'PAY_RESULT',
  'PAY_ERROR',
  'PAY_RESET',

  'FETCH_PRICING_START',
  'FETCH_PRICING_RESULT',
  'FETCH_PRICING_ERROR',
  'FETCH_PRICING_RESET',

  'FEEDBACK_START',
  'FEEDBACK_RESULT',
  'FEEDBACK_ERROR',
  'FEEDBACK_RESET',

  'CLOSE_DIARY',

  'CHOOSE_DIARY_START',
  'CHOOSE_DIARY_RESULT',
  'CHOOSE_DIARY_ERROR',
  'CHOOSE_DIARY_RESET',

  'LOGIN_START',
  'LOGIN_RESULT',
  'LOGIN_ERROR',
  'LOGIN_RESET',

  'LOGOUT_START',
  'LOGOUT_RESULT',
  'LOGOUT_ERROR',
  

  'ACCOUNT_DATA_UPDATED',

  'SIGN_UP_START',
  'SIGN_UP_PROGRESS',
  'SIGN_UP_RESULT',
  'SIGN_UP_ERROR',
  'SIGN_UP_RESET',

  'AUTH_WITH_SERVER_START',
  'AUTH_WITH_SERVER_RESULT',
  'AUTH_WITH_SERVER_ERROR',
  'AUTH_WITH_SERVER_RESET',

  'OPEN_DIARY_START',
  'OPEN_DIARY_RESULT',
  'OPEN_DIARY_ERROR',
  'OPEN_DIARY_RESET',

  'CREATE_DIARY_START',
  'CREATE_DIARY_RESULT',
  'CREATE_DIARY_ERROR',
  'CREATE_DIARY_RESET',

  'ENABLE_CLOUD_SYNC_START',
  'ENABLE_CLOUD_SYNC_PROGRESS',
  'ENABLE_CLOUD_SYNC_RESULT',
  'ENABLE_CLOUD_SYNC_ERROR',
  'ENABLE_CLOUD_SYNC_RESET',

  'LOAD_ENTRIES_START',
  'LOAD_ENTRIES_PROGRESS',
  'LOAD_ENTRIES_RESULT',
  'LOAD_ENTRIES_ERROR',

  'LOAD_SETTINGS_START',
  'LOAD_SETTINGS_RESULT',
  'LOAD_SETTINGS_ERROR',

  'BACKUP_START',
  'BACKUP_RESULT',
  'BACKUP_ERROR',
  'BACKUP_RESET',

  'RESTORE_START',
  'RESTORE_PROGRESS',
  'RESTORE_RESULT',
  'RESTORE_ERROR',
  'RESTORE_RESET',

  'RESTORE_FROM_OLD_START',
  'RESTORE_FROM_OLD_PROGRESS',
  'RESTORE_FROM_OLD_RESULT',
  'RESTORE_FROM_OLD_ERROR',
  'RESTORE_FROM_OLD_RESET',

  'DECRYPT_ENTRIES_START',
  'DECRYPT_ENTRIES_PROGRESS',
  'DECRYPT_ENTRIES_RESULT',
  'DECRYPT_ENTRIES_ERROR',
  'DECRYPT_ENTRIES_RESET',

  'DERIVE_KEYS_START',
  'DERIVE_KEYS_PROGRESS',
  'DERIVE_KEYS_RESULT',
  'DERIVE_KEYS_ERROR',

  'UPDATE_ENTRY_START',
  'UPDATE_ENTRY_RESULT',
  'UPDATE_ENTRY_ERROR',
  'UPDATE_ENTRY_RESET',  

  'DELETE_ENTRY_START',
  'DELETE_ENTRY_RESULT',
  'DELETE_ENTRY_ERROR',
  'DELETE_ENTRY_RESET',

  'CHANGE_PASSWORD_START',
  'CHANGE_PASSWORD_RESULT',
  'CHANGE_PASSWORD_ERROR',
  'CHANGE_PASSWORD_RESET',

  'EXPORT_DATA_START',
  'EXPORT_DATA_RESULT',
  'EXPORT_DATA_ERROR',
  'EXPORT_DATA_RESET',

  'BUILD_SEARCH_INDEX_START',
  'BUILD_SEARCH_INDEX_RESULT',
  'BUILD_SEARCH_INDEX_ERROR',

  'SEARCH_START',
  'SEARCH_RESULT',
  'SEARCH_ERROR',
];

var Actions = exports.Actions = {};

actionTypes.forEach(function(type) {
  Actions[type] = type;
});



export function buildAction(type, payload = {}) {
  if (payload && payload instanceof Error) {
    payload = {
      error: payload
    };
  }

  return {
    type: type,
    payload: payload,
  };
};



