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

Commit

Permalink
Merge pull request #14218 from NejcZdovc/fix/#10767-fix
Browse files Browse the repository at this point in the history
Fixes WebTorrent not being enabled
  • Loading branch information
bsclifton committed May 23, 2018
1 parent 961cfdf commit 03e86dd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
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

0 comments on commit 03e86dd

Please sign in to comment.