Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\FirstRunWizard\Listener\AppEnabledListener;
use OCA\FirstRunWizard\Listener\BeforeFilesAppTemplateRenderedListener;
use OCA\FirstRunWizard\Listener\BeforeTemplateRenderedListener;
use OCA\FirstRunWizard\Notification\Notifier;
use OCP\App\ManagerEvent;
Expand All @@ -44,8 +43,6 @@ public function __construct() {
public function register(IRegistrationContext $context): void {
$context->registerEventListener(ManagerEvent::EVENT_APP_ENABLE, AppEnabledListener::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
// Display the first run wizard only on the files app,
$context->registerEventListener(LoadAdditionalScriptsEvent::class, BeforeFilesAppTemplateRenderedListener::class);
}

public function boot(IBootContext $context): void {
Expand Down
73 changes: 0 additions & 73 deletions lib/Listener/BeforeFilesAppTemplateRenderedListener.php

This file was deleted.

45 changes: 44 additions & 1 deletion lib/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,62 @@

namespace OCA\FirstRunWizard\Listener;

use OCA\FirstRunWizard\Notification\AppHint;
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserSession;

class BeforeTemplateRenderedListener implements IEventListener {
public function __construct() {
/**
* @var IUserSession
*/
private $userSession;
/**
* @var IConfig
*/
private $config;
/**
* @var AppHint
*/
private $appHint;
/**
* @var IJobList
*/
private $jobList;

public function __construct(
IConfig $config,
IUserSession $userSession,
IJobList $jobList,
AppHint $appHint
) {
$this->userSession = $userSession;
$this->config = $config;
$this->appHint = $appHint;
$this->jobList = $jobList;
}

public function handle(Event $event): void {
if (!$event instanceof BeforeTemplateRenderedEvent || !$event->isLoggedIn()) {
return;
}

$user = $this->userSession->getUser();
if (!$user instanceof IUser) {
return;
}

if ($this->config->getUserValue($user->getUID(), 'firstrunwizard', 'show', '1') !== '0') {
\OC_Util::addScript('firstrunwizard', 'activate');

$this->jobList->add('OCA\FirstRunWizard\Notification\BackgroundJob', ['uid' => $this->userSession->getUser()->getUID()]);
}
$this->appHint->sendAppHintNotifications();

\OC_Util::addScript('firstrunwizard', 'about');
}
}