fixes: Wrong position change indicator when >100

This commit is contained in:
Towfiq 2022-12-24 08:28:09 +06:00
parent be5ec96699
commit 74c9603293
2 changed files with 7 additions and 1 deletions

View File

@ -56,6 +56,9 @@ const Keyword = (props: KeywordProps) => {
const historySorted = historyArray.sort((a, b) => a.date - b.date);
const previousPos = historySorted[historySorted.length - 2].position;
status = previousPos === 0 ? position : previousPos - position;
if (position === 0 && previousPos > 0) {
status = previousPos - 100;
}
}
return status;
}, [history, position]);

View File

@ -60,7 +60,10 @@ const getPositionChange = (history:KeywordHistory, position:number) : number =>
}));
const historySorted = historyArray.sort((a, b) => a.date - b.date);
const previousPos = historySorted[historySorted.length - 2].position;
status = previousPos - position;
status = previousPos === 0 ? position : previousPos - position;
if (position === 0 && previousPos > 0) {
status = previousPos - 100;
}
}
return status;
};