Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixes WebTorrent not being enabled #14218

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions app/common/state/extensionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
const Immutable = require('immutable')

// Constants
const config = require('../../../js/constants/config')
const settings = require('../../../js/constants/settings')

// Utils
Expand Down Expand Up @@ -220,10 +219,7 @@ const extensionState = {
}

const settingsState = state.get('settings')
const extension = extensionState.getExtensionById(state, config.torrentExtensionId)
const extensionEnabled = extension != null ? extension.get('enabled') : false
const torrentEnabled = getSetting(settings.TORRENT_VIEWER_ENABLED, settingsState)
return extensionEnabled && torrentEnabled
return getSetting(settings.TORRENT_VIEWER_ENABLED, settingsState)
}
}

Expand Down
25 changes: 3 additions & 22 deletions test/unit/app/common/state/extensionStateTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* global describe, it, before */
const extensionState = require('../../../../../app/common/state/extensionState')
const config = require('../../../../../js/constants/config')
const settings = require('../../../../../js/constants/settings')
const Immutable = require('immutable')
const assert = require('assert')
Expand Down Expand Up @@ -686,43 +685,25 @@ describe('extensionState', function () {
})

describe('isWebTorrentEnabled', function () {
const torrentId = config.torrentExtensionId

it('null case', function () {
const result = extensionState.isWebTorrentEnabled()
assert.equal(result, false)
})

it('empty state', function () {
it('torrent is enabled by default', function () {
const result = extensionState.isWebTorrentEnabled(defaultAppState)
assert.equal(result, false)
})

it('extension is disabled', function () {
const state = defaultAppState
.setIn(['extensions', torrentId], Immutable.fromJS({
enabled: false
}))
.setIn(['settings', settings.TORRENT_VIEWER_ENABLED], true)
const result = extensionState.isWebTorrentEnabled(state)
assert.equal(result, false)
assert.equal(result, true)
})

it('torrent is disabled', function () {
const state = defaultAppState
.setIn(['extensions', torrentId], Immutable.fromJS({
enabled: true
}))
.setIn(['settings', settings.TORRENT_VIEWER_ENABLED], false)
const result = extensionState.isWebTorrentEnabled(state)
assert.equal(result, false)
})

it('everything is enabled', function () {
it('torrent is enabled', function () {
const state = defaultAppState
.setIn(['extensions', torrentId], Immutable.fromJS({
enabled: true
}))
.setIn(['settings', settings.TORRENT_VIEWER_ENABLED], true)
const result = extensionState.isWebTorrentEnabled(state)
assert.equal(result, true)
Expand Down