Compare commits

..

3 Commits

Author SHA1 Message Date
Diego Rodríguez Baquero
1350f3f7cf fixes 2021-10-10 13:58:19 -05:00
Diego Rodríguez Baquero
08a182d165 standard fix 2021-10-10 13:51:38 -05:00
Diego Rodríguez Baquero
63b55df637 fix: modernify code 2021-10-10 13:49:13 -05:00
16 changed files with 6712 additions and 8339 deletions

View File

@@ -12,8 +12,8 @@ jobs:
node: node:
- '16' - '16'
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-node@v3 - uses: actions/setup-node@v2
with: with:
node-version: ${{ matrix.node }} node-version: ${{ matrix.node }}
- run: npm install - run: npm install

View File

@@ -5,11 +5,11 @@ jobs:
package_linux: package_linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-node@v3 - uses: actions/setup-node@v2
with: with:
node-version: '16' node-version: '16'
- uses: actions/cache@v3 - uses: actions/cache@v2
with: with:
path: ~/.npm path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -17,7 +17,7 @@ jobs:
${{ runner.os }}-node- ${{ runner.os }}-node-
- run: npm install - run: npm install
- run: npm run package -- linux - run: npm run package -- linux
- uses: actions/upload-artifact@v7 - uses: actions/upload-artifact@v2
with: with:
name: linux name: linux
path: | path: |
@@ -27,11 +27,11 @@ jobs:
package_macos: package_macos:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-node@v3 - uses: actions/setup-node@v2
with: with:
node-version: '16' node-version: '16'
- uses: actions/cache@v3 - uses: actions/cache@v2
with: with:
path: ~/.npm path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -39,7 +39,7 @@ jobs:
${{ runner.os }}-node- ${{ runner.os }}-node-
- run: npm install - run: npm install
- run: npm run package -- darwin - run: npm run package -- darwin
- uses: actions/upload-artifact@v7 - uses: actions/upload-artifact@v2
with: with:
name: macos name: macos
path: | path: |
@@ -48,11 +48,11 @@ jobs:
package_windows: package_windows:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
- uses: actions/setup-node@v3 - uses: actions/setup-node@v2
with: with:
node-version: '16' node-version: '16'
- uses: actions/cache@v3 - uses: actions/cache@v2
with: with:
path: ~/.npm path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
@@ -60,7 +60,7 @@ jobs:
${{ runner.os }}-node- ${{ runner.os }}-node-
- run: npm install - run: npm install
- run: npm run package -- win32 - run: npm run package -- win32
- uses: actions/upload-artifact@v7 - uses: actions/upload-artifact@v2
with: with:
name: windows name: windows
path: | path: |

View File

@@ -12,12 +12,12 @@ jobs:
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v6 - uses: actions/stale@v4
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' stale-issue-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?' stale-pr-message: 'Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?'
exempt-issue-labels: accepted,blocked,dependency,security,meta exempt-issue-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
exempt-pr-labels: accepted,blocked,bug,dependency,security,meta exempt-pr-labels: accepted,blocked,bug,dependency,enhancement,'help wanted',question,security,meta
stale-issue-label: 'stale' stale-issue-label: 'stale'
stale-pr-label: 'stale' stale-pr-label: 'stale'

View File

@@ -13,7 +13,7 @@
<p align="center"> <p align="center">
<a href="https://discord.gg/cnXkm4Z"><img src="https://img.shields.io/discord/612575111718895616" alt="discord"></a> <a href="https://discord.gg/cnXkm4Z"><img src="https://img.shields.io/discord/612575111718895616" alt="discord"></a>
<a href="https://github.com/webtorrent/webtorrent-desktop/actions/workflows/ci.yml"><img src="https://github.com/webtorrent/webtorrent-desktop/actions/workflows/ci.yml/badge.svg" alt="GitHub CI action"></a> <a href="https://travis-ci.org/webtorrent/webtorrent-desktop"><img src="https://img.shields.io/travis/webtorrent/webtorrent-desktop/master.svg" alt="travis"></a>
<a href="https://github.com/webtorrent/webtorrent-desktop/releases"><img src="https://img.shields.io/github/release/webtorrent/webtorrent-desktop.svg" alt="github release version"></a> <a href="https://github.com/webtorrent/webtorrent-desktop/releases"><img src="https://img.shields.io/github/release/webtorrent/webtorrent-desktop.svg" alt="github release version"></a>
<a href="https://github.com/webtorrent/webtorrent-desktop/releases"><img src="https://img.shields.io/github/downloads/webtorrent/webtorrent-desktop/total.svg" alt="github release downloads"></a> <a href="https://github.com/webtorrent/webtorrent-desktop/releases"><img src="https://img.shields.io/github/downloads/webtorrent/webtorrent-desktop/total.svg" alt="github release downloads"></a>
<a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard - JavaScript Style Guide"></a> <a href="https://standardjs.com"><img src="https://img.shields.io/badge/code_style-standard-brightgreen.svg" alt="Standard - JavaScript Style Guide"></a>
@@ -147,7 +147,7 @@ to be installed. For example on Mac, first install
[XQuartz](http://www.xquartz.org/), then run: [XQuartz](http://www.xquartz.org/), then run:
``` ```
$ brew install wine mono brew install wine mono
``` ```
(Requires the [Homebrew](http://brew.sh/) package manager.) (Requires the [Homebrew](http://brew.sh/) package manager.)

14803
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -21,68 +21,68 @@
"url": "https://github.com/webtorrent/webtorrent-desktop/issues" "url": "https://github.com/webtorrent/webtorrent-desktop/issues"
}, },
"dependencies": { "dependencies": {
"@electron/remote": "2.1.3", "@electron/remote": "2.0.1",
"airplayer": "github:webtorrent/airplayer#fix-security", "airplayer": "github:webtorrent/airplayer#fix-security",
"application-config": "2.0.0", "application-config": "2.0.0",
"arch": "2.2.0", "arch": "2.2.0",
"auto-launch": "5.0.5", "auto-launch": "5.0.5",
"bitfield": "4.1.0", "bitfield": "4.0.0",
"capture-frame": "4.0.0", "capture-frame": "4.0.0",
"chokidar": "3.5.3", "chokidar": "3.5.2",
"chromecasts": "1.10.2", "chromecasts": "1.10.2",
"create-torrent": "5.0.9", "create-torrent": "5.0.1",
"debounce": "1.2.1", "debounce": "1.2.1",
"dlnacasts": "0.1.0", "dlnacasts": "0.1.0",
"drag-drop": "7.2.0", "drag-drop": "7.2.0",
"es6-error": "4.1.1", "es6-error": "4.1.1",
"fn-getter": "1.0.0", "fn-getter": "1.0.0",
"iso-639-1": "2.1.15", "iso-639-1": "2.1.9",
"languagedetect": "2.0.0", "languagedetect": "2.0.0",
"location-history": "1.1.2", "location-history": "1.1.2",
"material-ui": "0.20.2", "material-ui": "0.20.2",
"music-metadata": "7.14.0", "music-metadata": "7.11.4",
"network-address": "1.1.2", "network-address": "1.1.2",
"parse-torrent": "9.1.5", "parse-torrent": "9.1.4",
"prettier-bytes": "1.0.4", "prettier-bytes": "1.0.4",
"prop-types": "15.8.1", "prop-types": "15.7.2",
"react": "17.0.2", "react": "17.0.2",
"react-dom": "17.0.2", "react-dom": "17.0.2",
"rimraf": "4.4.0", "rimraf": "3.0.2",
"run-parallel": "1.2.0", "run-parallel": "1.2.0",
"semver": "7.3.8", "semver": "7.3.5",
"simple-concat": "1.0.1", "simple-concat": "1.0.1",
"simple-get": "4.0.1", "simple-get": "4.0.0",
"srt-to-vtt": "1.1.3", "srt-to-vtt": "1.1.3",
"vlc-command": "1.2.0", "vlc-command": "1.2.0",
"webtorrent": "1.9.7", "webtorrent": "1.5.6",
"winreg": "1.2.4" "winreg": "1.2.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "7.28.6", "@babel/cli": "7.15.7",
"@babel/core": "7.29.0", "@babel/core": "7.15.8",
"@babel/eslint-parser": "7.28.6", "@babel/eslint-parser": "7.15.8",
"@babel/plugin-transform-react-jsx": "7.28.6", "@babel/plugin-transform-react-jsx": "7.14.9",
"cross-zip": "4.0.0", "cross-zip": "4.0.0",
"depcheck": "1.4.7", "depcheck": "1.4.2",
"electron": "27.3.11", "electron": "15.1.2",
"electron-notarize": "1.2.2", "electron-notarize": "1.1.1",
"electron-osx-sign": "0.6.0", "electron-osx-sign": "0.5.0",
"electron-packager": "17.1.2", "electron-packager": "15.4.0",
"electron-winstaller": "5.4.0", "electron-winstaller": "5.0.0",
"gh-release": "7.0.2", "gh-release": "6.0.1",
"minimist": "1.2.8", "minimist": "1.2.5",
"nodemon": "2.0.22", "nodemon": "2.0.13",
"open": "8.4.2", "open": "8.3.0",
"plist": "3.1.0", "plist": "3.0.4",
"pngjs": "7.0.0", "pngjs": "6.0.0",
"run-series": "1.1.9", "run-series": "1.1.9",
"spectron": "19.0.0", "spectron": "15.0.0",
"standard": "17.0.0", "standard": "16.0.4",
"tape": "5.9.0" "tape": "5.3.1"
}, },
"engines": { "engines": {
"node": "^16.0.0 || ^18.0.0", "node": "^16.0.0",
"npm": "^7.10.0 || ^8.0.0 || ^9.0.0 || ^10.0.0" "npm": "^7.10.0 || ^8.0.0"
}, },
"homepage": "https://webtorrent.io", "homepage": "https://webtorrent.io",
"keywords": [ "keywords": [
@@ -99,8 +99,8 @@
"main": "index.js", "main": "index.js",
"optionalDependencies": { "optionalDependencies": {
"appdmg": "^0.6.0", "appdmg": "^0.6.0",
"electron-installer-debian": "^3.2.0", "electron-installer-debian": "^3.1.0",
"electron-installer-redhat": "^3.4.0" "electron-installer-redhat": "^3.3.0"
}, },
"private": true, "private": true,
"productName": "WebTorrent", "productName": "WebTorrent",

View File

@@ -91,11 +91,11 @@ function init (state, options) {
}) })
win.on('move', debounce(e => { win.on('move', debounce(e => {
send('windowBoundsChanged', main.win.getBounds()) send('windowBoundsChanged', e.sender.getBounds())
}, 1000)) }, 1000))
win.on('resize', debounce(e => { win.on('resize', debounce(e => {
send('windowBoundsChanged', main.win.getBounds()) send('windowBoundsChanged', e.sender.getBounds())
}, 1000)) }, 1000))
win.on('close', e => { win.on('close', e => {

View File

@@ -11,7 +11,6 @@ class Header extends React.Component {
onMouseMove={dispatcher('mediaMouseMoved')} onMouseMove={dispatcher('mediaMouseMoved')}
onMouseEnter={dispatcher('mediaControlsMouseEnter')} onMouseEnter={dispatcher('mediaControlsMouseEnter')}
onMouseLeave={dispatcher('mediaControlsMouseLeave')} onMouseLeave={dispatcher('mediaControlsMouseLeave')}
role='navigation'
> >
{this.getTitle()} {this.getTitle()}
<div className='nav left float-left'> <div className='nav left float-left'>
@@ -19,9 +18,6 @@ class Header extends React.Component {
className={'icon back ' + (loc.hasBack() ? '' : 'disabled')} className={'icon back ' + (loc.hasBack() ? '' : 'disabled')}
title='Back' title='Back'
onClick={dispatcher('back')} onClick={dispatcher('back')}
role='button'
aria-disabled={!loc.hasBack()}
aria-label='Back'
> >
chevron_left chevron_left
</i> </i>
@@ -29,9 +25,6 @@ class Header extends React.Component {
className={'icon forward ' + (loc.hasForward() ? '' : 'disabled')} className={'icon forward ' + (loc.hasForward() ? '' : 'disabled')}
title='Forward' title='Forward'
onClick={dispatcher('forward')} onClick={dispatcher('forward')}
role='button'
aria-disabled={!loc.hasForward()}
aria-label='Forward'
> >
chevron_right chevron_right
</i> </i>
@@ -57,7 +50,6 @@ class Header extends React.Component {
className='icon add' className='icon add'
title='Add torrent' title='Add torrent'
onClick={dispatcher('openFiles')} onClick={dispatcher('openFiles')}
role='button'
> >
add add
</i> </i>

View File

@@ -113,10 +113,6 @@ module.exports = class TorrentListController {
} }
} }
setGlobalTrackers (globalTrackers) {
ipcRenderer.send('wt-set-global-trackers', globalTrackers)
}
// TODO: use torrentKey, not infoHash // TODO: use torrentKey, not infoHash
toggleTorrent (infoHash) { toggleTorrent (infoHash) {
const torrentSummary = TorrentSummary.getByKey(this.state, infoHash) const torrentSummary = TorrentSummary.getByKey(this.state, infoHash)

View File

@@ -144,7 +144,7 @@ function chromecastPlayer () {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Transfer-Encoding': 'chunked' 'Transfer-Encoding': 'chunked'
}) })
res.end(Buffer.from(selectedSubtitle.buffer.slice(21), 'base64')) res.end(Buffer.from(selectedSubtitle.buffer.substr(21), 'base64'))
}).listen(0, () => { }).listen(0, () => {
const port = ret.subServer.address().port const port = ret.subServer.address().port
const subtitlesUrl = 'http://' + state.server.networkAddress + ':' + port + '/' const subtitlesUrl = 'http://' + state.server.networkAddress + ':' + port + '/'

View File

@@ -3,7 +3,6 @@ const path = require('path')
const { EventEmitter } = require('events') const { EventEmitter } = require('events')
const config = require('../../config') const config = require('../../config')
const defaultAnnounceList = require('create-torrent').announceList.map((arr) => arr[0])
const SAVE_DEBOUNCE_INTERVAL = 1000 const SAVE_DEBOUNCE_INTERVAL = 1000
@@ -80,7 +79,6 @@ function getDefaultState () {
getPlayingTorrentSummary, getPlayingTorrentSummary,
getPlayingFileSummary, getPlayingFileSummary,
getExternalPlayerName, getExternalPlayerName,
getGlobalTrackers,
shouldHidePlayerControls shouldHidePlayerControls
} }
} }
@@ -131,8 +129,7 @@ function setupStateSaved () {
soundNotifications: true, soundNotifications: true,
autoAddTorrents: false, autoAddTorrents: false,
torrentsFolderPath: '', torrentsFolderPath: '',
highestPlaybackPriority: true, highestPlaybackPriority: true
globalTrackers: defaultAnnounceList
}, },
torrents: config.DEFAULT_TORRENTS.map(createTorrentObject), torrents: config.DEFAULT_TORRENTS.map(createTorrentObject),
torrentsToResume: [], torrentsToResume: [],
@@ -201,15 +198,8 @@ function shouldHidePlayerControls () {
new Date().getTime() - this.playing.mouseStationarySince > 2000 && new Date().getTime() - this.playing.mouseStationarySince > 2000 &&
!this.playing.mouseInControls && !this.playing.mouseInControls &&
!this.playing.isPaused && !this.playing.isPaused &&
this.playing.location === 'local' this.playing.location === 'local' &&
} this.playing.playbackRate === 1
function getGlobalTrackers () {
const trackers = this.saved.prefs.globalTrackers
if (!trackers) {
return defaultAnnounceList
}
return trackers
} }
async function load (cb) { async function load (cb) {

View File

@@ -124,9 +124,6 @@ function onState (err, _state) {
} }
}) })
// Give global trackers
setGlobalTrackers()
// Restart everything we were torrenting last time the app ran // Restart everything we were torrenting last time the app ran
resumeTorrents() resumeTorrents()
@@ -317,7 +314,6 @@ const dispatchHandlers = {
preferences: () => controllers.prefs().show(), preferences: () => controllers.prefs().show(),
updatePreferences: (key, value) => controllers.prefs().update(key, value), updatePreferences: (key, value) => controllers.prefs().update(key, value),
checkDownloadPath, checkDownloadPath,
updateGlobalTrackers: (trackers) => setGlobalTrackers(trackers),
startFolderWatcher: () => controllers.folderWatcher().start(), startFolderWatcher: () => controllers.folderWatcher().start(),
stopFolderWatcher: () => controllers.folderWatcher().stop(), stopFolderWatcher: () => controllers.folderWatcher().stop(),
@@ -420,10 +416,6 @@ function escapeBack () {
} }
} }
function setGlobalTrackers () {
controllers.torrentList().setGlobalTrackers(state.getGlobalTrackers())
}
// Starts all torrents that aren't paused on program startup // Starts all torrents that aren't paused on program startup
function resumeTorrents () { function resumeTorrents () {
state.saved.torrents state.saved.torrents

View File

@@ -1,5 +1,3 @@
/* globals MediaMetadata */
const React = require('react') const React = require('react')
const BitField = require('bitfield').default const BitField = require('bitfield').default
const prettyBytes = require('prettier-bytes') const prettyBytes = require('prettier-bytes')
@@ -37,7 +35,6 @@ module.exports = class Player extends React.Component {
tag.pause() tag.pause()
tag.src = '' tag.src = ''
tag.load() tag.load()
navigator.mediaSession.metadata = null
} }
} }
@@ -54,28 +51,6 @@ function renderMedia (state) {
// Get the <video> or <audio> tag // Get the <video> or <audio> tag
const mediaElement = document.querySelector(state.playing.type) const mediaElement = document.querySelector(state.playing.type)
if (mediaElement !== null) { if (mediaElement !== null) {
if (navigator.mediaSession.metadata === null && mediaElement.played.length !== 0) {
navigator.mediaSession.metadata = new MediaMetadata({
title: state.playing.fileName
})
navigator.mediaSession.setActionHandler('pause', () => {
dispatch('playPause')
})
navigator.mediaSession.setActionHandler('play', () => {
dispatch('playPause')
})
if (Playlist.hasNext(state)) {
navigator.mediaSession.setActionHandler('nexttrack', () => {
dispatch('nextTrack')
})
}
if (Playlist.hasPrevious(state)) {
navigator.mediaSession.setActionHandler('previoustrack', () => {
dispatch('previousTrack')
})
}
}
if (state.playing.isPaused && !mediaElement.paused) { if (state.playing.isPaused && !mediaElement.paused) {
mediaElement.pause() mediaElement.pause()
} else if (!state.playing.isPaused && mediaElement.paused) { } else if (!state.playing.isPaused && mediaElement.paused) {
@@ -635,8 +610,6 @@ function renderPlayerControls (state) {
key='skip-previous' key='skip-previous'
className={'icon skip-previous float-left ' + prevClass} className={'icon skip-previous float-left ' + prevClass}
onClick={dispatcher('previousTrack')} onClick={dispatcher('previousTrack')}
role='button'
aria-label='Previous track'
> >
skip_previous skip_previous
</i>, </i>,
@@ -645,8 +618,6 @@ function renderPlayerControls (state) {
key='play' key='play'
className='icon play-pause float-left' className='icon play-pause float-left'
onClick={dispatcher('playPause')} onClick={dispatcher('playPause')}
role='button'
aria-label={state.playing.isPaused ? 'Play' : 'Pause'}
> >
{state.playing.isPaused ? 'play_arrow' : 'pause'} {state.playing.isPaused ? 'play_arrow' : 'pause'}
</i>, </i>,
@@ -655,8 +626,6 @@ function renderPlayerControls (state) {
key='skip-next' key='skip-next'
className={'icon skip-next float-left ' + nextClass} className={'icon skip-next float-left ' + nextClass}
onClick={dispatcher('nextTrack')} onClick={dispatcher('nextTrack')}
role='button'
aria-label='Next track'
> >
skip_next skip_next
</i>, </i>,
@@ -665,8 +634,6 @@ function renderPlayerControls (state) {
key='fullscreen' key='fullscreen'
className='icon fullscreen float-right' className='icon fullscreen float-right'
onClick={dispatcher('toggleFullScreen')} onClick={dispatcher('toggleFullScreen')}
role='button'
aria-label={state.window.isFullScreen ? 'Exit full screen' : 'Enter full screen'}
> >
{state.window.isFullScreen ? 'fullscreen_exit' : 'fullscreen'} {state.window.isFullScreen ? 'fullscreen_exit' : 'fullscreen'}
</i> </i>
@@ -679,8 +646,6 @@ function renderPlayerControls (state) {
key='subtitles' key='subtitles'
className={'icon closed-caption float-right ' + captionsClass} className={'icon closed-caption float-right ' + captionsClass}
onClick={handleSubtitles} onClick={handleSubtitles}
role='button'
aria-label='Closed captions'
> >
closed_caption closed_caption
</i> </i>
@@ -762,8 +727,6 @@ function renderPlayerControls (state) {
<i <i
className='icon volume-icon float-left' className='icon volume-icon float-left'
onMouseDown={handleVolumeMute} onMouseDown={handleVolumeMute}
role='button'
aria-label='Mute'
> >
{volumeIcon} {volumeIcon}
</i> </i>

View File

@@ -4,7 +4,6 @@ const PropTypes = require('prop-types')
const colors = require('material-ui/styles/colors') const colors = require('material-ui/styles/colors')
const Checkbox = require('material-ui/Checkbox').default const Checkbox = require('material-ui/Checkbox').default
const RaisedButton = require('material-ui/RaisedButton').default const RaisedButton = require('material-ui/RaisedButton').default
const TextField = require('material-ui/TextField').default
const Heading = require('../components/heading') const Heading = require('../components/heading')
const PathSelector = require('../components/path-selector') const PathSelector = require('../components/path-selector')
@@ -29,15 +28,6 @@ class PreferencesPage extends React.Component {
this.handleSoundNotificationsChange = this.handleSoundNotificationsChange =
this.handleSoundNotificationsChange.bind(this) this.handleSoundNotificationsChange.bind(this)
this.handleSetGlobalTrackers =
this.handleSetGlobalTrackers.bind(this)
const globalTrackers = this.props.state.getGlobalTrackers().join('\n')
this.state = {
globalTrackers
}
} }
downloadPathSelector () { downloadPathSelector () {
@@ -239,39 +229,6 @@ class PreferencesPage extends React.Component {
dispatch('updatePreferences', 'isFileHandler', true) dispatch('updatePreferences', 'isFileHandler', true)
} }
setGlobalTrackers () {
// Align the text fields
const textFieldStyle = { width: '100%' }
const textareaStyle = { margin: 0 }
return (
<Preference>
<TextField
className='torrent-trackers control'
style={textFieldStyle}
textareaStyle={textareaStyle}
multiLine
rows={2}
rowsMax={10}
value={this.state.globalTrackers}
onChange={this.handleSetGlobalTrackers}
/>
</Preference>
)
}
handleSetGlobalTrackers (e, globalTrackers) {
this.setState({ globalTrackers })
const announceList = globalTrackers
.split('\n')
.map((s) => s.trim())
.filter((s) => s !== '')
dispatch('updatePreferences', 'globalTrackers', announceList)
dispatch('updateGlobalTrackers', announceList)
}
render () { render () {
const style = { const style = {
color: colors.grey400, color: colors.grey400,
@@ -297,9 +254,6 @@ class PreferencesPage extends React.Component {
{this.setStartupCheckbox()} {this.setStartupCheckbox()}
{this.soundNotificationsCheckbox()} {this.soundNotificationsCheckbox()}
</PreferencesSection> </PreferencesSection>
<PreferencesSection title='Trackers'>
{this.setGlobalTrackers()}
</PreferencesSection>
</div> </div>
) )
} }

View File

@@ -4,6 +4,7 @@ console.time('init')
const crypto = require('crypto') const crypto = require('crypto')
const util = require('util') const util = require('util')
const defaultAnnounceList = require('create-torrent').announceList
const { ipcRenderer } = require('electron') const { ipcRenderer } = require('electron')
const fs = require('fs') const fs = require('fs')
const mm = require('music-metadata') const mm = require('music-metadata')
@@ -15,6 +16,11 @@ const config = require('../config')
const { TorrentKeyNotFoundError } = require('./lib/errors') const { TorrentKeyNotFoundError } = require('./lib/errors')
const torrentPoster = require('./lib/torrent-poster') const torrentPoster = require('./lib/torrent-poster')
// Force use of webtorrent trackers on all torrents
globalThis.WEBTORRENT_ANNOUNCE = defaultAnnounceList
.map((arr) => arr[0])
.filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0)
/** /**
* WebTorrent version. * WebTorrent version.
*/ */
@@ -59,8 +65,6 @@ init()
function init () { function init () {
listenToClientEvents() listenToClientEvents()
ipcRenderer.on('wt-set-global-trackers', (e, globalTrackers) =>
setGlobalTrackers(globalTrackers))
ipcRenderer.on('wt-start-torrenting', (e, torrentKey, torrentID, path, fileModtimes, selections) => ipcRenderer.on('wt-start-torrenting', (e, torrentKey, torrentID, path, fileModtimes, selections) =>
startTorrenting(torrentKey, torrentID, path, fileModtimes, selections)) startTorrenting(torrentKey, torrentID, path, fileModtimes, selections))
ipcRenderer.on('wt-stop-torrenting', (e, infoHash) => ipcRenderer.on('wt-stop-torrenting', (e, infoHash) =>
@@ -95,11 +99,6 @@ function listenToClientEvents () {
client.on('error', (err) => ipcRenderer.send('wt-error', null, err.message)) client.on('error', (err) => ipcRenderer.send('wt-error', null, err.message))
} }
// Sets the default trackers
function setGlobalTrackers (globalTrackers) {
globalThis.WEBTORRENT_ANNOUNCE = globalTrackers
}
// Starts a given TorrentID, which can be an infohash, magnet URI, etc. // Starts a given TorrentID, which can be an infohash, magnet URI, etc.
// Returns a WebTorrent object. See https://git.io/vik9M // Returns a WebTorrent object. See https://git.io/vik9M
function startTorrenting (torrentKey, torrentID, path, fileModtimes, selections) { function startTorrenting (torrentKey, torrentID, path, fileModtimes, selections) {

View File

@@ -71,6 +71,7 @@ table {
.app { .app {
-webkit-user-select: none; -webkit-user-select: none;
-webkit-app-region: drag;
height: 100%; height: 100%;
display: flex; display: flex;
flex-flow: column; flex-flow: column;
@@ -142,7 +143,6 @@ table {
*/ */
.header { .header {
-webkit-app-region: drag;
background: rgb(40, 40, 40); background: rgb(40, 40, 40);
border-bottom: 1px solid rgb(30, 30, 30); border-bottom: 1px solid rgb(30, 30, 30);
height: 38px; /* vertically center OS menu buttons (OS X) */ height: 38px; /* vertically center OS menu buttons (OS X) */