Skip to content

Commit bea8c51

Browse files
committed
chore(viewer): drop the bundled viewer app
Nothing needs it any more: the handlers come from @nextcloud/viewer, core puts the init script on every page, and the enabled preview providers are a core capability. With it goes the LoadViewer event, which three places dispatched behind a class_exists() guard to ask the app to load itself. An app that wants a file view imports the package and registers a handler; it no longer matters whether the viewer app is enabled, or which app got there first. The app config rows left behind on an upgrade are cleaned up by the repair step that already does this for the other apps we dropped. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent ed5a96b commit bea8c51

9 files changed

Lines changed: 6 additions & 42 deletions

File tree

apps/files/lib/Controller/ViewController.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use OCA\Files\Event\LoadSidebar;
1818
use OCA\Files\Service\UserConfig;
1919
use OCA\Files\Service\ViewConfig;
20-
use OCA\Viewer\Event\LoadViewer;
2120
use OCP\App\IAppManager;
2221
use OCP\AppFramework\Controller;
2322
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
@@ -197,10 +196,6 @@ public function index($dir = '', $view = '', $fileid = null) {
197196
$this->eventDispatcher->dispatchTyped(new ResourcesLoadAdditionalScriptsEvent());
198197
$this->eventDispatcher->dispatchTyped(new LoadSidebar());
199198
$this->eventDispatcher->dispatchTyped(new LoadSearchPlugins());
200-
// Load Viewer scripts
201-
if (class_exists(LoadViewer::class)) {
202-
$this->eventDispatcher->dispatchTyped(new LoadViewer());
203-
}
204199

205200
$this->initialState->provideInitialState('templates_enabled', true);
206201
$this->initialState->provideInitialState('templates_path', $this->templateManager->hasTemplateDirectory() ? $this->templateManager->getTemplatePath() : false);

apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use OCA\FederatedFileSharing\FederatedShareProvider;
1212
use OCA\Files_Sharing\AppInfo\Application;
1313
use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
14-
use OCA\Viewer\Event\LoadViewer;
1514
use OCP\Accounts\IAccountManager;
1615
use OCP\AppFramework\Http\ContentSecurityPolicy;
1716
use OCP\AppFramework\Http\Template\ExternalShareMenuAction;
@@ -118,11 +117,6 @@ public function renderPage(IShare $share, string $token, string $path): Template
118117
$isFileRequest = $attributes?->getAttribute('fileRequest', 'enabled') === true;
119118
$this->initialState->provideInitialState('isFileRequest', $isFileRequest);
120119

121-
// Load Viewer scripts
122-
if (class_exists(LoadViewer::class)) {
123-
$this->eventDispatcher->dispatchTyped(new LoadViewer());
124-
}
125-
126120
$this->initialState->provideInitialState('templates', $this->templateManager->listCreators());
127121

128122
// Allow external apps to register their scripts

apps/settings/lib/Settings/Personal/ServerDevNotice.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
namespace OCA\Settings\Settings\Personal;
99

10-
use OCA\Viewer\Event\LoadViewer;
1110
use OCP\AppFramework\Http\TemplateResponse;
1211
use OCP\AppFramework\Services\IInitialState;
13-
use OCP\EventDispatcher\IEventDispatcher;
1412
use OCP\Files\IRootFolder;
1513
use OCP\IURLGenerator;
1614
use OCP\IUserSession;
@@ -22,7 +20,6 @@ class ServerDevNotice implements ISettings {
2220

2321
public function __construct(
2422
private IRegistry $registry,
25-
private IEventDispatcher $eventDispatcher,
2623
private IRootFolder $rootFolder,
2724
private IUserSession $userSession,
2825
private IInitialState $initialState,
@@ -39,12 +36,9 @@ public function getForm(): TemplateResponse {
3936

4037
$hasInitialState = false;
4138

42-
// If the Reasons to use Nextcloud.pdf file is here, let's init Viewer, also check that Viewer is there
43-
if (class_exists(LoadViewer::class) && $userFolder->nodeExists('Reasons to use Nextcloud.pdf')) {
44-
/**
45-
* @psalm-suppress UndefinedClass, InvalidArgument
46-
*/
47-
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
39+
// The viewer loads itself; this only decides whether the notice has
40+
// a file to point at
41+
if ($userFolder->nodeExists('Reasons to use Nextcloud.pdf')) {
4842
$hasInitialState = true;
4943
}
5044

build/integration/features/provisioning-v1.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,6 @@ Feature: provisioning
658658
| updatenotification |
659659
| user_ldap |
660660
| user_status |
661-
| viewer |
662661
| workflowengine |
663662
| webhook_listeners |
664663
| weather_status |

build/psalm-baseline.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,11 +2335,6 @@
23352335
<code><![CDATA[provideInitialState]]></code>
23362336
</DeprecatedMethod>
23372337
</file>
2338-
<file src="apps/settings/lib/Settings/Personal/ServerDevNotice.php">
2339-
<DeprecatedMethod>
2340-
<code><![CDATA[dispatch]]></code>
2341-
</DeprecatedMethod>
2342-
</file>
23432338
<file src="apps/settings/lib/SetupChecks/CheckUserCertificates.php">
23442339
<DeprecatedMethod>
23452340
<code><![CDATA[getAppValue]]></code>

core/shipped.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"updatenotification",
5454
"user_ldap",
5555
"user_status",
56-
"viewer",
5756
"weather_status",
5857
"webhook_listeners",
5958
"workflowengine"
@@ -102,7 +101,6 @@
102101
"twofactor_totp",
103102
"updatenotification",
104103
"user_status",
105-
"viewer",
106104
"weather_status",
107105
"webhook_listeners"
108106
],
@@ -120,7 +118,6 @@
120118
"sharing",
121119
"theming",
122120
"twofactor_backupcodes",
123-
"viewer",
124121
"workflowengine"
125122
]
126123
}

lib/private/Repair/CleanUpAbandonedApps.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use OCP\Migration\IRepairStep;
1414

1515
class CleanUpAbandonedApps implements IRepairStep {
16-
protected const ABANDONED_APPS = ['accessibility', 'files_videoplayer'];
16+
protected const ABANDONED_APPS = ['accessibility', 'files_videoplayer', 'viewer'];
1717

1818
public function __construct(
1919
private readonly IConfig $config,

tests/lib/App/AppManagerTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ public function testGetEnabledApps(): void {
564564
'test3',
565565
'theming',
566566
'twofactor_backupcodes',
567-
'viewer',
568567
'workflowengine',
569568
];
570569
$this->assertEquals($apps, $this->manager->getEnabledApps());
@@ -597,7 +596,6 @@ public function testGetAppsForUser(): void {
597596
'test3',
598597
'theming',
599598
'twofactor_backupcodes',
600-
'viewer',
601599
'workflowengine',
602600
];
603601
$this->assertEquals($enabled, $this->manager->getEnabledAppsForUser($user));
@@ -638,7 +636,6 @@ public function testGetAppsNeedingUpgrade(): void {
638636
'sharing' => ['id' => 'sharing'],
639637
'theming' => ['id' => 'theming'],
640638
'twofactor_backupcodes' => ['id' => 'twofactor_backupcodes'],
641-
'viewer' => ['id' => 'viewer'],
642639
'workflowengine' => ['id' => 'workflowengine'],
643640
'oauth2' => ['id' => 'oauth2'],
644641
];
@@ -703,7 +700,6 @@ public function testGetIncompatibleApps(): void {
703700
'twofactor_backupcodes' => ['id' => 'twofactor_backupcodes'],
704701
'workflowengine' => ['id' => 'workflowengine'],
705702
'oauth2' => ['id' => 'oauth2'],
706-
'viewer' => ['id' => 'viewer'],
707703
];
708704

709705
$manager->expects($this->any())
@@ -751,7 +747,6 @@ public function testGetEnabledAppsForGroup(): void {
751747
'test3',
752748
'theming',
753749
'twofactor_backupcodes',
754-
'viewer',
755750
'workflowengine',
756751
];
757752
$this->assertEquals($enabled, $this->manager->getEnabledAppsForGroup($group));

tests/lib/AppTest.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ public static function appConfigValuesProvider(): array {
109109
'sharing',
110110
'theming',
111111
'twofactor_backupcodes',
112-
'viewer',
113112
'workflowengine',
114113
],
115114
false
@@ -135,7 +134,6 @@ public static function appConfigValuesProvider(): array {
135134
'sharing',
136135
'theming',
137136
'twofactor_backupcodes',
138-
'viewer',
139137
'workflowengine',
140138
],
141139
false
@@ -162,7 +160,6 @@ public static function appConfigValuesProvider(): array {
162160
'sharing',
163161
'theming',
164162
'twofactor_backupcodes',
165-
'viewer',
166163
'workflowengine',
167164
],
168165
false
@@ -189,7 +186,6 @@ public static function appConfigValuesProvider(): array {
189186
'sharing',
190187
'theming',
191188
'twofactor_backupcodes',
192-
'viewer',
193189
'workflowengine',
194190
],
195191
false,
@@ -216,7 +212,6 @@ public static function appConfigValuesProvider(): array {
216212
'sharing',
217213
'theming',
218214
'twofactor_backupcodes',
219-
'viewer',
220215
'workflowengine',
221216
],
222217
true,
@@ -279,11 +274,11 @@ public function testEnabledAppsCache(): void {
279274
);
280275

281276
$apps = \OC_App::getEnabledApps();
282-
$this->assertEquals(['files', 'app3', 'appstore', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'profile', 'provisioning_api', 'settings', 'sharing', 'theming', 'twofactor_backupcodes', 'viewer', 'workflowengine'], $apps);
277+
$this->assertEquals(['files', 'app3', 'appstore', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'profile', 'provisioning_api', 'settings', 'sharing', 'theming', 'twofactor_backupcodes', 'workflowengine'], $apps);
283278

284279
// mock should not be called again here
285280
$apps = \OC_App::getEnabledApps();
286-
$this->assertEquals(['files', 'app3', 'appstore', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'profile', 'provisioning_api', 'settings', 'sharing', 'theming', 'twofactor_backupcodes', 'viewer', 'workflowengine'], $apps);
281+
$this->assertEquals(['files', 'app3', 'appstore', 'cloud_federation_api', 'dav', 'federatedfilesharing', 'lookup_server_connector', 'oauth2', 'profile', 'provisioning_api', 'settings', 'sharing', 'theming', 'twofactor_backupcodes', 'workflowengine'], $apps);
287282

288283
$this->restoreAppConfig();
289284
$userSession->setUser(null);

0 commit comments

Comments
 (0)