Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to get file model in template picker #30440

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

julien-nc
Copy link
Member

If the template picker creates a file which is not immediately rendered in the file list, it fails to get the FileInfoModel (which is then passed to the default file action). This does not break the Text app because its file action does not use the FileInfoModel. It does break the OnlyOffice app (and maybe others) file creation from a template.

The template picker fails to get the model because FileList::getModelForFile() relies on the DOM and the freshly created file is sometimes not added/rendered.

The created file item is not rendered if the target position is out of what's currently visible/loaded.

Fortunately, FileList::addAndFetchFileInfo() fetches the file metadata and we can use it to generate the file model in the template picker.
I switched from await to .then() because I couldn't find another way to get the promise result when multiple parameters are passed to resolve().

We have to be careful when backporting this. So far, I saw that a few changes are necessary to make it work in stable22.

@julien-nc julien-nc added this to the Nextcloud 24 milestone Dec 29, 2021
@julien-nc julien-nc requested review from juliusknorr, a team, PVince81, skjnldsv and szaimen and removed request for a team December 29, 2021 14:12
Copy link
Member

@juliusknorr juliusknorr left a comment

Choose a reason for hiding this comment

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

Could not trigger it myself but change seems good 👍

@julien-nc julien-nc force-pushed the fix/noid/templatePicker-fileInfoModel branch 2 times, most recently from 1cecb10 to 6bf38db Compare December 29, 2021 16:40
@skjnldsv
Copy link
Member

Lint failures

apps/files/src/views/TemplatePicker.vue Outdated Show resolved Hide resolved
@julien-nc julien-nc force-pushed the fix/noid/templatePicker-fileInfoModel branch from 6bf38db to c69da07 Compare December 30, 2021 09:40
@julien-nc
Copy link
Member Author

This can be backported in 21, 22 and 23 IMO.

@artonge
Copy link
Contributor

artonge commented Dec 30, 2021

/compile amend /

@artonge
Copy link
Contributor

artonge commented Dec 30, 2021

/backport to 23

@artonge
Copy link
Contributor

artonge commented Dec 30, 2021

/backport to 22

@artonge
Copy link
Contributor

artonge commented Dec 30, 2021

/backport to 21

Signed-off-by: Julien Veyssier <[email protected]>
Signed-off-by: nextcloud-command <[email protected]>
@nextcloud-command nextcloud-command force-pushed the fix/noid/templatePicker-fileInfoModel branch from c69da07 to 4d32f11 Compare December 30, 2021 10:09
@artonge
Copy link
Contributor

artonge commented Dec 30, 2021

CI failure is unrelated. Merge when you want @eneiluj :)

@juliusknorr juliusknorr merged commit e40828d into master Dec 30, 2021
@juliusknorr juliusknorr deleted the fix/noid/templatePicker-fileInfoModel branch December 30, 2021 13:54
@backportbot-nextcloud
Copy link

The backport to 21 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to 22 failed. Please do this backport manually.

@solracsf
Copy link
Member

/backport to stable23

@solracsf
Copy link
Member

/backport to stable22

@solracsf
Copy link
Member

/backport to stable21

@backportbot-nextcloud
Copy link

The backport to 23 failed. Please do this backport manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants