Simplify: use Util::addStyle in boot()
This commit is contained in:
@@ -8,10 +8,6 @@ use OCP\AppFramework\App;
|
||||
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\EventDispatcher\Event;
|
||||
use OCP\EventDispatcher\IEventListener;
|
||||
use OCP\IConfig;
|
||||
use OCP\Util;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
@@ -23,39 +19,13 @@ class Application extends App implements IBootstrap {
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
$context->registerEventListener(
|
||||
TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN,
|
||||
function(Event $event) {
|
||||
if ($event instanceof TemplateResponse) {
|
||||
$config = $event->getAppContainer()->query(IConfig::class);
|
||||
$value = $config->getAppValue('minimalprofile', 'hidden_fields', '');
|
||||
$hidden = ($value !== '') ? json_decode($value, true) ?? [] : [];
|
||||
|
||||
$css = '';
|
||||
if (!empty($hidden)) {
|
||||
$selectors = [
|
||||
'pronouns' => '#account-property-pronouns',
|
||||
'role' => '#account-property-role',
|
||||
'headline' => '#account-property-headline',
|
||||
];
|
||||
foreach ($hidden as $field) {
|
||||
if (isset($selectors[$field])) {
|
||||
$css .= $selectors[$field] . ' { display: none !important; }' . "\n";
|
||||
$css .= '.personal-settings-setting-box:has(' . $selectors[$field] . ') { display: none !important; }' . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($css) {
|
||||
Util::addInlineStyle($css);
|
||||
}
|
||||
|
||||
file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' EVENT fired, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
// Load CSS from our css/ folder using standard Util::addStyle
|
||||
// This loads css/minimalprofile.css
|
||||
Util::addStyle('minimalprofile', 'minimalprofile');
|
||||
|
||||
file_put_contents('/tmp/minimalprofile.log', date('Y-m-d H:i:s') . ' boot, loaded style' . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user