-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Allow downloading multiple images into one directory #7030
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I tried to re-use as much existing code as possible and not mutate existing functions.
That's why I added an additional saveAttachments()
function that takes an array of attachments, opens a directory picker dialog once and uses this base directory for all files.
One could probably combine the functionality to save a single attachment (with a user-defined name) and multiple attachments into one common function, but I didn't want to risk breaking too much existing functionality.
If wanted, I can use saveAttachments()
for single attachments as well, skip the showSaveMultiDialog()
call if the array's length is one and set dirPath
to undefined.
ts/state/ducks/conversations.ts
Outdated
// TODO shouldn't we throw some kind of error here? Original code also doesn't do anything, but... | ||
if (fullPath == null) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In saveAttachments()
(so the function to download a single attachment), I guess this was a check to skip showing the toast, when the user cancels the download/ file picker dialog.
Since I'm doing this check a few lines above, we probably should either remove this check here completely or throw an error, because something went wrong in the Attachments.save()
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this should probably be a throw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed that, please check the error message.
kickOffAttachmentDownload({ | ||
attachment, | ||
messageId: id, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably want a toast here telling the user why the save dialog isn't showing up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like "Can't save attachment, since it hasn't finished downloading yet." ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, probably pluralized for the single vs. multiple case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new toast type and an action "showAttachmentDownloadStillInProgressToast" for this.
Hope that was correct, but I didn't know how to show the toast otherwise.
dispatch({ | ||
type: SHOW_TOAST, | ||
payload: { | ||
toastType: ToastType.FileSaved, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new toast for this situation, because the toast currently says the singular 'Attachment saved.' instead of listing the number saved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(or a pluralized toast, with a number parameter or something)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pluralized the toast message if multiple attachments are saved.
@@ -23,7 +23,7 @@ import type { | |||
PropsData as MessagePropsData, | |||
PropsHousekeeping, | |||
} from './Message'; | |||
import type { PushPanelForConversationActionType } from '../../state/ducks/conversations'; | |||
import { type PushPanelForConversationActionType } from '../../state/ducks/conversations'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want the type
to be outside the braces, in fact. That's generally how we do things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reverted the change, but shouldn't npm run format
take care of this.
I cannot remember that I did this change intentionally and had hoped that Prettier will include a rule for these imports.
}, | ||
"icu:attachmentSavedShow": { | ||
"messageformat": "Im Ordner anzeigen" | ||
}, | ||
"icu:attachmentStillDownloading": { | ||
"messageformat": "{count, plural, one {Anhang kann} other {Anhänge können}} nicht gespeichert werden, da {count, plural, one {er} other {#}} noch nicht fertig heruntergeladen {count, plural, one {wurde} other {wurden}}." | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't modify the non-english files - those are managed by our translators. This will be overwritten the next time we pull strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I wasn't sure how to interpret this "You only need to modify the default locale _locales/en/messages.json." statement.
I thought this means that I have to modify the English file, but can edit other languages as well.
In my case this was necessary, because I had the Signal instance running in German and it crashed when the translated string wasn't present.
But if I understand you correctly, this means that I can leave the string as is?
I think we're ready to merge this as soon as that last TODO is removed. Would you consider pushing a squashed version of all these changes, taking it down to one commit? |
Use download directory as default for single file downloads Check if any attachment is still pending Cleaning up comments Apply suggestions from code review Co-authored-by: Scott Nonnenberg <[email protected]> Add more changes from code review Revert change to default path in show-save-dialog method Add toast when attachment download is still in progress + pluralize FileSaved toast + fix linter errors Remove unnecessary comment More changes from code review Remove comment Remove comment
d0d7358
to
99eeb9f
Compare
Done, I hope the PR is ready now 🙂 |
Thanks for all of your work on this - it was merged internally, and is now available in our latest beta: https://github.com/signalapp/Signal-Desktop/releases/tag/v7.31.0-beta.1 You can see the final commit here: 76e2597 |
I'm glad (and a bit proud ;) to see my changes finally merged. Thanks for your great support during development ❤️ |
First time contributor checklist:
Contributor checklist:
main
branchnpm run ready
run passes successfully (more about tests here)Description
Describe briefly what your pull request changes. Focus on the value provided to users.
Today I noticed, that right now it's not possible to download multiple images at once, which makes saving large galleries to the disk very time-consuming.
I was very surprised why this is the case, given that downloading a single image works without problems.
So I decided that I could maybe take a look into the code and try to fix things on my own, because the feature requests regarding this issue have not seen any attention for 3 years.
My experience with React is basically non-existent, so it was a lot of copy-pasting and adjusting the existing approach to download a single attachment.
It took a while to understand the data-flow between the different files, functions and actions, but I got it to work 🥳
I would like to get some feedback on my approach, then I can clean it up, maybe add some tests (although I would need some guidance on how to write these, maybe a similar example) and rebase it.
Does it address any outstanding issues in this project?
Please write a summary of your test approach:
Edit: In addition to my regular Manjaro Linux system, I successfully tested the changes with Windows 11 as well.