Skip to content

Commit

Permalink
fix: translate popup does not open in mobile apps
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <[email protected]>
  • Loading branch information
luka-nextcloud authored and juliushaertl committed Jan 16, 2024
1 parent 593fd8c commit d12a5be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/DirectEditing/TextDirectEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

use OCA\Text\AppInfo\Application;
use OCA\Text\Service\ApiService;
use OCA\Text\Service\InitialStateProvider;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\DirectEditing\IEditor;
use OCP\DirectEditing\IToken;
use OCP\Files\InvalidPathException;
Expand All @@ -42,15 +42,15 @@ class TextDirectEditor implements IEditor {
/** @var IL10N */
private $l10n;

/** @var IInitialState */
private $initialStateService;
/** @var InitialStateProvider */
private $initialStateProvider;

/** @var ApiService */
private $apiService;

public function __construct(IL10N $l10n, IInitialState $initialStateService, ApiService $apiService) {
public function __construct(IL10N $l10n, InitialStateProvider $initialStateProvider, ApiService $apiService) {
$this->l10n = $l10n;
$this->initialStateService = $initialStateService;
$this->initialStateProvider = $initialStateProvider;
$this->apiService = $apiService;
}

Expand Down Expand Up @@ -153,12 +153,13 @@ public function open(IToken $token): Response {
$token->useTokenScope();
try {
$session = $this->apiService->create($token->getFile()->getId());
$this->initialStateService->provideInitialState('file', [
$this->initialStateProvider->provideFile([
'fileId' => $token->getFile()->getId(),
'mimetype' => $token->getFile()->getMimeType(),
'session' => \json_encode($session->getData())
]);
$this->initialStateService->provideInitialState('directEditingToken', $token->getToken());
$this->initialStateProvider->provideDirectEditToken($token->getToken());
$this->initialStateProvider->provideState();
Util::addScript('text', 'text-text');
return new TemplateResponse('text', 'main', [], 'base');
} catch (InvalidPathException $e) {
Expand Down
8 changes: 8 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@ public function provideState(): void {
public function provideFileId(int $fileId): void {
$this->initialState->provideInitialState('file_id', $fileId);
}

public function provideFile(array $fileData): void {
$this->initialState->provideInitialState('file', $fileData);
}

public function provideDirectEditToken(string $token): void {
$this->initialState->provideInitialState('directEditingToken', $token);
}
}

0 comments on commit d12a5be

Please sign in to comment.