pbaity / rocketchat-dark-mode

An easy user-togglable dark mode for Rocket.Chat
MIT License
367 stars 125 forks source link

Support for Rocket.Chat 3.18.2? #157

Closed hammondr closed 2 years ago

hammondr commented 2 years ago

We upgraded to RC 3.18.2 last night and pasted the custom CSS and JS but it doesn't seem to have any effect.

Should this be working on 3.18.2? Does anyone know what changes would be required to support 3.18.2?

pbaity commented 2 years ago

@hammondr I haven't upgraded yet (still at 3.18.1) but yes, it's intended to work. I'll see about testing it out soon to see if I can find the issue (new releases often give us a little trouble here) but in the meantime, can you tell me what you're seeing exactly? Does the dark mode button not appear?

hammondr commented 2 years ago

Correct, the dark mode button does not appear.

scornet256 commented 2 years ago

It does work here as expected on version 3.18.3 (snap).

pbaity commented 2 years ago

I also use the snap, so I think I got upgraded from 3.18.1 to 3.18.3. In any case I never noticed this problem. @hammondr is this still an issue for you?

hammondr commented 2 years ago

Yes, I am still not able to get this to work in 3.18.2. It has worked for us in earlier RC versions. I just tried again by removing all of the content from the Layout > Custom CSS and Layout > Custom Scripts > Custom Script for Logged In Users sections and replaced them with the content from the 3.18.3 branch here.

I use the rocketchat MacOS app but the web-based app has the same behavior. The dark mode button is not visible.

I just used Chrome developer tools and it is reporting a console error about unexpected end of input in the file where the custom JS is injected (in a later method): image

hammondr commented 2 years ago

If I remove the custom JS, I can see that the scripts.js file should end like this:

window.addEventListener('load', function() {
    if (window.localStorage) {
        Object.keys(window.localStorage).forEach(function(key) {
            window.sessionStorage.setItem(key, window.localStorage.getItem(key));
        });
        window.localStorage.clear();
        Meteor._localStorage = window.sessionStorage;
    }
});

So my file is being truncated when the dark mode custom JS is in there.

hammondr commented 2 years ago

If I remove the non-english internationalization strings from https://github.com/pbaity/rocketchat-dark-mode/blob/3.18.3/dark-mode-toggle.js#L27-L37, then my scripts.js doesn't get truncated and the dark mode button appears (and works).

pbaity commented 2 years ago

Ah, this has been reported before (I thought this sounded familiar!), and interestingly the script seemed to get truncated at the same spot. I have no idea why this happens, but it seems to be a Rocket.Chat bug unrelated to the dark mode script. It seems like shortening the script solves the problem, so yes, you can remove unneeded code or you could possibly minify the script, if upgrading your Rocket.Chat instance is not an option.

pbaity commented 2 years ago

Closing since this seems to be a Rocket.Chat bug unrelated to our dark mode script.