fix: open file guid filename - WPB-23112#4266
Conversation
…ame for the downloaded file
Test Results2 629 tests 2 629 ✅ 4m 49s ⏱️ Results for commit 79f8fe4. ♻️ This comment has been updated with latest results. Summary: workflow run #21748567356 |
samwyndham
left a comment
There was a problem hiding this comment.
question: We are using the UIKit version of quicklook previews now right? Did you attempt to set the filename using https://developer.apple.com/documentation/quicklookui/qlpreviewitem/previewitemtitle
There is a place where we use the UIKit version, but that is just a workaround for a bug that was causing the quicklook preview to automatically close on ipad. |
| let pathWithoutExtension: String = if extensionComponents.count > 1 { | ||
| String(extensionComponents.dropLast().joined(separator: ".")) | ||
| } else { | ||
| asset.cacheKey |
There was a problem hiding this comment.
Does it make sense to cover the else branch with the unit tests?
There was a problem hiding this comment.
Now that you mention it, I think the else case will never trigger, actually. Because the cacheKey is built always with the pattern:
uuid + "_" + some_other_id + "." + file_extension
and then the new key becomes uuid + "_" + some_other_id + "/" + filename_with_extension
The else case is just a defensive fallback.
We can't test it.
There was a problem hiding this comment.
Actually I don't know what would happen if we had files without a file extension.
There was a problem hiding this comment.
I added a unit test for files without extensions. Thanks for the suggestion.
|


Issue
Files are downloaded locally and are given a long unreadable id as the filename. When we open them for preview, we see that unreadable filename.
My first idea was to just change the appearance of the filename in the preview view, but that's not possible because the "quicklook preview" system component that we are using always shows the filename from the source URL that it was given.
We can't just download the files with their readable filename because there would be conflicts with same filenames from different conversations, different folders and different file versions (from editing).
Temporary copying a file just for preview would also be not optimal, especially when the file is large.
So my solution is to download the files into folders with the names of the former filenames (unreadable ids) and inside those folders the filenames are the readable proper names of the files.
The quicklook preview doesn't show the folder names but only the clean filenames.
And there should be no conflicts of filenames because each of them is in a unique folder.
Testing
Checklist
[WPB-XXX].UI accessibility checklist
If your PR includes UI changes, please utilize this checklist: