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

Handle PWA launches for both magnet urls and torrent files #596

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

CoryG89
Copy link

@CoryG89 CoryG89 commented Sep 16, 2022

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.json where I've added procotol_handlers, file_handlers, and launch_handler properties.
    • in client/src/javascript/components/AppWrapper.tsx where I'm calling window.launchQueue.setConsumer to detect when the app is launched with a torrent file.
  • 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:

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

Successfully merging this pull request may close these issues.

None yet

1 participant