Skip to content
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

fix(web): correctly display new logs when the same log appear multiple times #974

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

WaterLemons2k
Copy link
Contributor

@WaterLemons2k WaterLemons2k commented Jan 12, 2024

What does this PR do?

When the same log appears multiple times, using indexOf will get the index of the first time, so a new log will always pop up even if there is no new log.

Using lastIndexOf will fix this.


For example, we have the following logs:

const logsList = ["foo", "bar", "bar"];
const oldLogItem = "bar";

Using indexOf:

const newLogsList = logsList.slice(logsList.indexOf(oldLogItem) + 1);
console.log(newLogsList); // 'bar'

It will always have a new log.

Using lastIndexOf:

const newLogsList = logsList.slice(logsList.lastIndexOf(oldLogItem) + 1);
console.log(newLogsList); // []

There are no new logs.

Motivation

The same log may appear multiple times.

Additional Notes

HTML is formatted with Prettier, in a separate commit (82cb616).

@WaterLemons2k WaterLemons2k changed the title fix(web): correctly display new logs when old log appear multiple times fix(web): correctly display new logs when the same log appear multiple times Jan 12, 2024
@jeessy2 jeessy2 merged commit 01d3f4d into jeessy2:master Jan 12, 2024
2 checks passed
@jeessy2
Copy link
Owner

jeessy2 commented Jan 12, 2024

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants