Uh oh!
There was an error while loading. Please reload this page.
feat: only get template fields once selected - #52514
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as outdated.
This comment was marked as outdated.
9112dce to
4f8e51eCompareskjnldsv
commented
May 14, 2025
Awesome, thanks for this! |
Uh oh!
There was an error while loading. Please reload this page.
susnux
commented
May 15, 2025
OCP changes need to be documented in the app upgrade guides in the developer docs afterwards |
4e5780c to
18de6fdCompareSigned-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
18de6fd to
5c7216fCompareSigned-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
elzody
commented
May 19, 2025
/compile |
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
juliusknorr
commented
May 20, 2025
Just noticed now, I would have marked as a bugfix, @elzody Since the backport would need manual adjustments to be backward compatible with 31 can you take care of that? |
juliusknorr
commented
May 20, 2025
/backport to stable31 |
pedropintosilva
commented
May 20, 2025
Awesome, thanks 🥳 |
mmeeks
commented
May 21, 2025
Great to see the fix - thanks ! =) I had always assumed we just cached large thumbnails of the templates in the object store (as I assume we do for the file thumbnail view) and serve / re-use those for the template selector - is that not the case ? |
elzody
commented
May 21, 2025
@mmeeks The issue was not the thumbnails, but rather the fact that we send each of those templates to Collabora for field/content control extraction via the extract/transform API. It was taking a long time to process those, so now it just skips that when displaying them, and will only send the template to have the content controls extracted once the user selects which one they want to use. And of course, once the content controls are returned, we cache them on our side for the future, unless the template file itself changes (in which case we re-fetch them because they might have changed), or after a certain amount of time (I forgot how long off the top of my head). |
mmeeks
commented
May 21, 2025
Wonderful =) thanks Elizabeth. |
Summary
Creating a new file from a template can take a very long time if browser cache is disabled, does not exist yet, or an incognito session is used. This is because the
TemplatePicker.vuecomponent requests all templates from the/ocs/v2.php/apps/files/api/v1/templatesendpoint, which includes all the extracted fields of each template. For office documents, this meant that, for each template file, a request was being made to Collabora one after the other, causing very poor performance. I tried to find a workaround for this in the richdocuments app (e.g. using concurrent requests), but was not able to find a viable solution that made a noticeable difference in performance.My solution is to add a new property to the
BeforeGetTemplatesEventclass, indicating whether or not the template fields should be extracted. This allows more fine-grained control, as if you only want the templates but don't want to waste compute or wait on I/O to extract the template fields, you can passfalseas a value forwithFields, which is the default. If you do want the fields, you passtrue. This is used for the new endpoint, so the front end can call it to get the fields for whatever template is selected.You can find the related richdocuments pull request above, which includes tests.
Screen Recordings
Performance before
template-picker-slow-loading.mp4
Performance after
template-picker-fast-loading.mp4
Checklist