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

Auto add public trackers for magnet/torrent task #162

Closed
wants to merge 5 commits into from

Conversation

boin
Copy link
Contributor

@boin boin commented Dec 21, 2020

try implementing issue #137

**- add a configuration option to enable "adding public trackers"; **

There is a new conf option called "Automatically add trackers to new tasks form a trackslist URL", and also the option to specify tracker url. eg: https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best_ip.txt

- if the option is checked, for each successfully created task, add the additional trackers from the list above. (There is tracker adding API available for download station API)

My solution is slightly different: trackers when you adding new magnet/torrents before sending to DS-API.

Appreciate for any help/comments ❤️ and thanks to @seansfkelley for such a great work.

Copy link
Owner

@seansfkelley seansfkelley left a comment

Choose a reason for hiding this comment

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

Hello again, thanks so much for taking the time to do this!

I think your basic approach to insert the trackers at the time the task is added makes sense. The outlines of your implementation also make sense, though I've left some comments around how to make it match the surrounding code better and be more robust.

The review I just did is incomplete -- I tried to point out some changes that will probably require a bunch of moving code around, but I haven't actually tried to use this feature myself yet. Once I do, I think I'll have some more comments (mostly around how it feels to the user), but I wanted to get back to you reasonably soon.

Thanks again!

src/common/state/1.ts Show resolved Hide resolved
src/settings/index.tsx Show resolved Hide resolved
src/settings/index.tsx Show resolved Hide resolved
@@ -51,6 +51,8 @@ export function onStoredStateChange(storedState: State) {
backgroundState.showNonErrorNotifications =
storedState.settings.notifications.enableFeedbackNotifications;

backgroundState.torrentTrackers = updateAndGetTorrentTrackers(storedState);
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer a shift of responsibility around this call that looks kind of like the notifications block, above. Something like:

  • The background task state keeps a copy of the settings, rather than the file in actions/.
  • When the settings changes, it's this code (and not updateAndGetTorrentTrackers) that decides if anything needs to be done.
  • It passes the bare minimum of information to other methods that they need to do their jobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So your are suggesting not the module itself but backgroundStates to hold cachedTrackersList? I'll try it.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah. backgroundState is the place to store anything long-lived that doesn't belong as part of the configuration of the extension. Earlier versions of the code actually used the pattern you had here, but I changed it because it got too hard to manage.

src/background/actions/urls.ts Show resolved Hide resolved
console.debug("updateAndGetTorrentTrackers was called", new Error().stack);
console.debug("cached trackers:", cachedTrackers.length);

const flag = storedState.settings.torrentTrackers.enablePublicTrackers;
Copy link
Owner

Choose a reason for hiding this comment

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

I think there's a bug around this flag.

  1. User enables public trackers.
  2. The extension fetches and holds onto the list.
  3. User disables public trackers.
  4. User adds a new torrent task.
  5. Public trackers are added anyway.

I think something should clear the list if the flag is unset.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix later

)}
style={{ flex: 1 }}
value={this.state.publicTrackerURL}
onChange={(e) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Something in this chain of behavior needs to be debounced or otherwise delayed; as currently written, I think this is going to trigger a new request to load the tracker list on every keystroke, even while the URL is only partially written.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about "onblur" event?

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure how reliably onblur fires, especially if you do something like close the settings page without clicking outside of the input box. I'm imagining one of two solutions here:

  1. Debounce requests to the provided URL (you can use lodash-es/debounce), which doesn't involve any changes to the UI.
  2. Add a button to explicitly "save settings and fetch list", sort of like that which exists for the host/port/username/password configuration section. Changes to the UI required, but no clever debouncing or the like.

Having written these two down, I think the second is preferable: it's clearer about what's happening to the user, it follows existing UI patterns and it doesn't require much cleverness.

@VAllens
Copy link

VAllens commented Feb 16, 2021

GREAT !!!

@seansfkelley
Copy link
Owner

Hi, I appreciate you opening this PR but it looks like it's gone a little stale. I'm going to close it out so I can keep better track of what is and is not active on my bug tracker.

If you'd like to work on it again, let me know and I can reopen it.

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.

3 participants