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

Zero-values gives errors or empty cells #71

Closed
Olen opened this issue Aug 21, 2023 · 8 comments
Closed

Zero-values gives errors or empty cells #71

Olen opened this issue Aug 21, 2023 · 8 comments
Labels
bug Something isn't working frontend Related to the JavaScript code

Comments

@Olen
Copy link
Contributor

Olen commented Aug 21, 2023

Just creating this as a separate issue to keep track.

If all stats for a user is 0, the stats table does not load at all, and errors out with a "Cannot read property of undefined" or something similar (the error disppeared as soon as one of the scoreboard-values was updated to 1, so I don't have the exact error message in frnt of me anymore).

If just some values are 0, the table looks a bit strange as 0-values are not shown:

image

@Dantevg
Copy link
Owner

Dantevg commented Aug 21, 2023

Hiding cells with 0-values is intentional, as is hiding players with no scores (or only zeroes). WebStats handles having a score of 0 and having no score as the same thing. If you find the empty cells to look weird, an easy fix is adding a custom css file at plugins/WebStats/web/style.css. It's this one here, remove the :not(.empty) everywhere and add

td.empty::after {
  content: "0";
}

Do note that you'll need to manually update this file if it has changed in an update as this overrides the default one from the jar.

I think the "cannot read property of undefined" error may be coming from the fact that you're running the bedrock players PR. The error should still be present in the browser console, could you send me a screenshot of the stack trace there?

(thanks for keeping the issues separate :)

@Olen
Copy link
Contributor Author

Olen commented Aug 21, 2023

Found the error in the console log. It does not really give much info:

Uncaught (in promise) Error: "undefined" is not valid JSON
    at A (content.js:1:9544)

And the line it refers to is just

                        chrome.runtime.lastError ? chrome.runtime.lastError.message === r ? t() : e(chrome.runtime.lastError) : s && s.__mozWebExtensionPolyfillReject__ ? e(new Error(s.message)) : t(s)

This was after I joined the server with a (new) Java-player. I run a server that supports both java and bedrock. The whole table was gone and the error message appeared instead, but reappeared as soon as that new java-player had gotten at least one value in the scoreboard.

Thanks for the tip for 0-values btw..
Added the following css (I am using a custom index.html, so I just added it there), and the stats looks more like I want.

        td.empty {
                text-align: right;
                padding: 0px 30px;
                background: var(--bg1);
                text-align: right;
                transition: height 0.2s, padding 0.2s;
        }
        td.empty::after {
                content: "0";
        }

@Dantevg
Copy link
Owner

Dantevg commented Aug 21, 2023

That is a weird error. There is no code in WebStats with any chrome.runtime.lastError and there should never be malformatted JSON parsed. Are you sure that is the error that comes from WebStats?

@Olen
Copy link
Contributor Author

Olen commented Aug 22, 2023

There was (possibly) another error showing where the table should have been. The one from console.log is probably a more generic chrome-error.
I think there might be somewhere in the javascript code that does not handle a missing key in an array or something. But it is probably not a big deal as it went away after a few minutes when the scoreboard for the user started getting some values.

@Dantevg
Copy link
Owner

Dantevg commented Aug 26, 2023

Could it be that #72 is the error you were getting too? Since that one also seems to have something to do with a player having only 0 or empty stats.

@Olen
Copy link
Contributor Author

Olen commented Aug 26, 2023

This looks very much like the same error.

@Dantevg Dantevg added bug Something isn't working frontend Related to the JavaScript code labels Aug 26, 2023
@Dantevg
Copy link
Owner

Dantevg commented Aug 26, 2023

Hopefully it is, in which case it is fixed in the latest commit :)

As mentioned in #72 (comment), if you don't want to wait for the release you can put the new WebStats-dist.js in the right location yourself already.

@Olen
Copy link
Contributor Author

Olen commented Aug 26, 2023

Thanks. I just had to re-add my Bedrock-quickfix from #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Related to the JavaScript code
Projects
None yet
Development

No branches or pull requests

2 participants