Skip to content

Fix for Issuse #1474 #1565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions src/shared/reducers/page/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,27 @@ function mergeSkills(state, { type, payload, error }) {

let maxIsNew = 0;

// add skill logic
let addedSkillName = '';
let removedSkillName = '';
_.forEach(newSkills, (newSkill, tagId) => {
const oldSkill = oldSkills[tagId];
if (!oldSkill) {
if (!firstTime) {
maxIsNew += 1;
}
// Add the new skill and set 'isNew' field
mergedSkills[tagId] = {
...newSkill,
isNew: firstTime ? 0 : maxIsNew,
};
addedSkillName = newSkill.tagName;
} else if (!newSkill.hidden && oldSkill.hidden) {
addedSkillName = newSkill.tagName;
}
});

let removedSkillName = '';
// remove skill logic
_.forEach(oldSkills, (oldSkill, tagId) => {
const newSkill = newSkills[tagId];
if (!newSkill) {
Expand All @@ -64,35 +82,16 @@ function mergeSkills(state, { type, payload, error }) {
}
});

_.forEach(newSkills, (newSkill, tagId) => {
const oldSkill = oldSkills[tagId];
if (!oldSkill) {
if (!firstTime) {
maxIsNew += 1;
}
// Add the new skill and set 'isNew' field
mergedSkills[tagId] = {
...newSkill,
isNew: firstTime ? 0 : maxIsNew,
};
addedSkillName = newSkill.tagName;
} else if (!newSkill.hidden && oldSkill.hidden) {
addedSkillName = newSkill.tagName;
}
});

if (type === 'PROFILE/ADD_SKILL_DONE') {
if (payload.skill) {
toastrSuccess('Success! ', `Skill "${payload.skill.name}" was added.`);
} else {
toastrSuccess('Success! ', `Skill "${addedSkillName}" was added.`);
addedSkillName = payload.skill.name;
}
toastrSuccess('Success! ', `Skill "${addedSkillName}" was added.`);
} else if (type === 'PROFILE/HIDE_SKILL_DONE') {
if (payload.skill) {
toastrSuccess('Success! ', `Skill "${payload.skill.name}" was removed.`);
} else {
toastrSuccess('Success! ', `Skill "${removedSkillName}" was removed.`);
removedSkillName = payload.skill.name;
}
toastrSuccess('Success! ', `Skill "${removedSkillName}" was removed.`);
}

return {
Expand Down