Skip to content

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:

@trim21
Copy link
Collaborator

trim21 commented Jan 14, 2025

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.

}

if ('launchQueue' in window) {
window.launchQueue.setConsumer(async (launchParams) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be window.launchQueue?. I think

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.

2 participants