Skip to content

clean up *ByProp functions in notes getters

notes/stores/getters.js has some getter duplication - we have getSomeData (a regular getter) and getSomeDataByProp (function). For better consistency we can use the same method for both, with an optional prop.

current:

export const getUserData = state => state.userData || {};
export const getUserDataByProp = state => prop => state.userData && state.userData[prop];

proposed:

export const getUserData = state => (prop) => {
  const data = state.userData || defaultUserData;
  if (prop) {
    return data[prop];
  }
  return data;
};
Edited by 🤖 GitLab Bot 🤖