v1.0.28 - register calls addScript

This commit is contained in:
2026-04-16 16:41:53 +02:00
parent dd5651c3ee
commit f538bafa82
2 changed files with 4 additions and 34 deletions

View File

@@ -8,49 +8,19 @@ use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IConfig;
use OCP\Util;
class Application extends App implements IBootstrap {
public const APP_ID = 'minimalprofile';
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
parent::__construct('minimalprofile', $urlParams);
}
public function register(IRegistrationContext $context): void {
Util::addScript('minimalprofile', 'minimalprofile');
file_put_contents('/tmp/mp_register.log', date('Y-m-d H:i:s') . ' register added JS' . "\n", FILE_APPEND);
}
public function boot(IBootContext $context): void {
$container = $context->getAppContainer();
$config = $container->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";
}
}
} else {
// Debug
$css = 'body { border: 40px solid orange !important; }';
}
if ($css) {
Util::addInlineStyle($css);
}
// Also log to file as backup
file_put_contents('/tmp/minimalprofile_debug.log', date('Y-m-d H:i:s') . ' boot called, hidden: ' . print_r($hidden, true) . "\n", FILE_APPEND);
}
}