flood
flood copied to clipboard
Handle PWA launches for both magnet urls and torrent files
Description
This pull request enables launching Flood as a progressive web app (PWA) with OS integration via both magnet links and torrent files. I have been using these changes locally for a little while now and it is a big quality of life improvement so I thought I would share for anyone else who might be interested.
Screenshots
I uploaded a YouTube video demoing these changes using Microsoft Edge and Windows 11: https://www.youtube.com/watch?v=FfZ0nPHyZUk
All of the different combinations of launching with manet links as well as launching with one or more torrent files all worked as expected, the only exception is when the app is closed dragging multiple torrents onto the app icon just opens the app but does not open the add files dialog as expected (shown near the end of the video), this appears to be a bug with the PWA implementation in Edge/Windows, it works when the app is already open and you drag multiple torrent files onto the app icon, in this case the dialog opens as expected (also shown near the end of the video)
It should be possible to enable corresponding functionality with various other browser / operating system combinations. I tested Chrome / Windows 11 as well and was able to achieve equivalent functionality to the above video, though getting Windows to set the default app for the torrent file type was a bit finnicky, sometimes took a few tries, works every time with Edge.
Types of changes
- The main change can be found:
- in
client/src/public/manifest.jsonwhere I've addedprocotol_handlers,file_handlers, andlaunch_handlerproperties. - in
client/src/javascript/components/AppWrapper.tsxwhere I'm callingwindow.launchQueue.setConsumerto detect when the app is launched with a torrent file.
- in
- I also refactored the FileReader logic that was repeated in a few different files so that it could be reused for the new file handling logic while avoiding duplicating the same logic yet again. For this I created a new client
client/src/javascript/util/fileProcessor.ts
NOTE: To enable the full functionality including launching torrent files from the OS it does require setting a few flags in edge://flags or chrome://flags depending on your browser. How to set these flags as well as any other setup is shown in the YouTube video.
Relevant Links:
- https://web.dev/url-protocol-handler
- https://web.dev/file-handling
sorry for the 2 years late, jesec has been inactive for long time, and I just start to cleanup some old PR.
Never try PWA before, I need some time to read doc first.