Skip to content
Closed
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
9 changes: 9 additions & 0 deletions lib/Service/InitialStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use OCA\Richdocuments\TemplateManager;
use OCA\Theming\ImageManager;
use OCP\AppFramework\Services\IInitialState;
use OCA\Richdocuments\Service\SettingsService;
use OCP\Defaults;
use OCP\IConfig;
use OCP\IURLGenerator;
Expand All @@ -31,6 +32,7 @@ public function __construct(
private Defaults $themingDefaults,
private IConfig $config,
private ?string $userId,
private SettingsService $settingsService,
) {
}

Expand Down Expand Up @@ -110,5 +112,12 @@ private function provideOptions(): void {

$this->initialState->provideInitialState('theming-customLogo', $logo);
$this->initialState->provideInitialState('open_local_editor', $this->config->getAppValue(Application::APPNAME, 'open_local_editor', 'yes') === 'yes');
$fileName = $this->config->getUserValue($this->userId, Application::APPNAME, 'browsersetting');
if ($fileName) {
$browserSetting = $this->settingsService->getSettingsFile('userconfig/' . $this->userId,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather bad performance wise. File system access is rather slow and the initial state is built on every page load, so wondering if we shall rather write this to a memory cache

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re correct. We’re testing some features, and the patch will likely be discarded. If not, I’ll improve it. Thanks!

'browsersetting',
$fileName);
$this->initialState->provideInitialState('browsersetting', $browserSetting->getContent());
}
}
}
3 changes: 3 additions & 0 deletions lib/Service/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public function uploadFile(SettingsUrl $settingsUrl, string $fileData, string $u
$fileUri = $this->generateFileUri($settingsUrl->getType(), $settingsUrl->getCategory(), $fileName, $token['token']);
$this->refreshFolderEtag($settingsUrl->getType());

if ($settingsUrl->getType() === 'userconfig' && $settingsUrl->getCategory() === 'browsersetting') {
$this->config->setUserValue($userId, 'richdocuments', 'browsersetting', $fileName);
}
return [
'stamp' => $newFile->getETag(),
'uri' => $fileUri,
Expand Down
2 changes: 2 additions & 0 deletions src/view/Office.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<input name="theme" :value="formData.theme" type="hidden">
<input name="buy_product" value="https://nextcloud.com/pricing" type="hidden">
<input name="host_session_id" :value="formData.hostSessionID" type="hidden">
<input name="browser_setting" :value="formData.browserSetting" type="hidden">
</form>
<iframe :id="iframeId"
ref="documentFrame"
Expand Down Expand Up @@ -198,6 +199,7 @@ export default {
cssVariables: generateCSSVarTokens(),
theme: getCollaboraTheme(),
hostSessionID: 'nextcloud ' + OC.config.version + ' - richdocuments ' + getCapabilities().version,
browserSetting: loadState('richdocuments', 'browsersetting', ''),
},
}
},
Expand Down
Loading