This discussion started here. I’m hoping to continue it here instead of within that extension’s thread.
To possibly add what this extension does to core I first thought about the touch/no-touch class that is added to the body tag already. I was curious how that was done in core. I found it:
https://github.com/flarum/core/blob/98393707013647d4e6c4400fab41f5f3e67b0a04/js/src/common/Application.js#L220
But, we couldn’t just add this logged-in class code there right? Because code like app.session.user
won’t work in that file, correct? Or, will it?
Regardless, all that is needed is for this to run oninit:
const loggedin = app.session.user;
if (loggedin) {
var body = document.body;
body.classList.add("logged-in");
}
Or, no body variable:
const loggedin = app.session.user;
if (loggedin) {
document.body.classList.add("logged-in");
}
Or, for no other reason other than because it is used elsewhere, jQuery (in case we want all similar core code to look the same):
const loggedin = app.session.user;
if (loggedin) {
$(document.body).addClass('logged-in');
}
@luceos or @askvortsov: I’m betting you’ll know exactly where in core this should be added. I don’t need to do a pull request. A core dev could just pop this in somewhere.