zulip-desktop icon indicating copy to clipboard operation
zulip-desktop copied to clipboard

Added progress bar for electron

Open varun-s22 opened this issue 2 years ago • 7 comments

  • Added progress on the icon to show progress of files downloaded.
  • Dialog box for asking file location is switched on by default.
  • File location where the file is downloaded is opened by default.

What's this PR do? This PR is in reference to #1252 , where the user gets no notification about the file downloaded. This is currently Work in Progress, as it requires a review.

Any background context you want to provide? I used electron's native progress-bar to show the progress made on downloading. Since I didn't have the size of files downloaded, I used kind of a "hacky" way to deal out of it. If i could get the progress of how much file is being downloaded (i.e x MB/ y MB) format, I can show a real-time progress bar

Also this is currently below the

Screenshots? It currently looks like this Screenshot 2023-01-21 at 02 58 00

I have tested this PR on:

  • [ ] Windows
  • [ ] Linux/Ubuntu
  • [x] macOS

Future: I'm looking for external packages in TypeScript, which provides a progress-bar in the UI, so i can render a component on the screen itself.

varun-s22 avatar Jan 20 '23 21:01 varun-s22

@akashnimare @andersk @vsvipul Please if you could review this PR, it would be great.

varun-s22 avatar Jan 21 '23 14:01 varun-s22

https://user-images.githubusercontent.com/93476421/214092465-225c3f78-0024-4131-8cec-2dccd72ed44d.mov

This is how it currently looks. Look at the bottom of the dock icon, you can see the progress bar.

varun-s22 avatar Jan 23 '23 16:01 varun-s22

Thanks for the contribution! This looks to be just getting asymptotically close to 100%, with no notion of how long the downlaod actually will take. This may actually be more confusing for users, since they may be wondering why a big file is "stuck."

The download provides a Content-Length response header on it, which tells you how big the file is. You should be able to use this to make the progress bar accurate.

alexmv avatar Jan 23 '23 21:01 alexmv

Hey @alexmv, thanks for the review. I updated the file now. I didn't use Content-Length, as i couldn't pass the headers into WebContents. I had to change the entire downloading scheme, and use fetch for using the above. Instead I found a workaround, I explored the downloadItem in electron, and found two member functions which are useful for us, namely getTotalBytes(), and getReceivedBytes(), which solves our problem, and updates the progress bar live with the downloading of the file.

I hope now it works fine, and gets merged

varun-s22 avatar Jan 24 '23 12:01 varun-s22

This fixes #1252

varun-s22 avatar Jan 26 '23 20:01 varun-s22

hey @alexmv @andersk @timabbott, will you please review this PR?

varun-s22 avatar Feb 07 '23 22:02 varun-s22

Heads up @varun-s22, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

zulipbot avatar Mar 22 '24 22:03 zulipbot