Skip to content

Commit

Permalink
chore: Move away from deprecated app config api
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Jan 25, 2024
1 parent 0c26a32 commit 069787a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/Migration/ResetSessionsBeforeYjs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

use OCA\Text\Db\SessionMapper;
use OCA\Text\Service\DocumentService;
use OCP\IConfig;
use OCP\IAppConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class ResetSessionsBeforeYjs implements IRepairStep {
private IConfig $config;
private IAppConfig $config;
private SessionMapper $sessionMapper;
private DocumentService $documentService;

public function __construct(IConfig $config,
public function __construct(IAppConfig $config,
SessionMapper $sessionMapper,
DocumentService $documentService) {
$this->config = $config;
Expand All @@ -34,7 +34,7 @@ public function getName(): string {
* @return void
*/
public function run(IOutput $output): void {
$appVersion = $this->config->getAppValue('text', 'installed_version');
$appVersion = $this->config->getValueString('text', 'installed_version');

if (!$appVersion || version_compare($appVersion, '3.7.2') !== -1) {
return;
Expand Down
15 changes: 8 additions & 7 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
namespace OCA\Text\Service;

use OCA\Text\AppInfo\Application;
use OCP\IAppConfig;
use OCP\IConfig;

class ConfigService {
private IConfig $config;

public function __construct(IConfig $config) {
$this->config = $config;
public function __construct(
private IAppConfig $appConfig,
private IConfig $config,
) {
}

public function getDefaultFileExtension(): string {
return $this->config->getAppValue(Application::APP_NAME, 'default_file_extension', 'md');
return $this->appConfig->getValueString(Application::APP_NAME, 'default_file_extension', 'md');
}

public function isRichEditingEnabled(): bool {
return ($this->config->getAppValue(Application::APP_NAME, 'rich_editing_enabled', '1') === '1');
return ($this->appConfig->getValueString(Application::APP_NAME, 'rich_editing_enabled', '1') === '1');
}

public function isRichWorkspaceAvailable(): bool {
return $this->config->getAppValue(Application::APP_NAME, 'workspace_available', '1') === '1';
return $this->appConfig->getValueString(Application::APP_NAME, 'workspace_available', '1') === '1';
}

public function isRichWorkspaceEnabledForUser(?string $userId): bool {
Expand Down

0 comments on commit 069787a

Please sign in to comment.