When manually adding subtitle track(s), always switch to a new track

Also fix a bug I added in the parent commit
This commit is contained in:
DC
2016-05-16 08:41:02 -07:00
parent eeda7c17c5
commit d466ed085a
2 changed files with 7 additions and 3 deletions

View File

@@ -43,7 +43,7 @@ function init () {
app.setPath('userData', config.CONFIG_PATH) app.setPath('userData', config.CONFIG_PATH)
} }
app.isReady = false // app ready, windows can be created var isReady = false // app ready, windows can be created
app.ipcReady = false // main window has finished loading and IPC is ready app.ipcReady = false // main window has finished loading and IPC is ready
app.isQuitting = false app.isQuitting = false
@@ -58,7 +58,7 @@ function init () {
}) })
app.on('ready', function () { app.on('ready', function () {
app.isReady = true isReady = true
windows.createMainWindow() windows.createMainWindow()
windows.createWebTorrentHiddenWindow() windows.createWebTorrentHiddenWindow()
@@ -86,7 +86,7 @@ function init () {
}) })
app.on('activate', function () { app.on('activate', function () {
if (app.isReady) windows.createMainWindow() if (isReady) windows.createMainWindow()
}) })
} }

View File

@@ -423,6 +423,8 @@ function openSubtitles () {
properties: [ 'openFile' ] properties: [ 'openFile' ]
}, function (filenames) { }, function (filenames) {
if (!Array.isArray(filenames)) return if (!Array.isArray(filenames)) return
// autoselect the newly added subtitle tracks
state.playing.subtitles.selectedIndex = -1
addSubtitle({path: filenames[0]}, true) addSubtitle({path: filenames[0]}, true)
}) })
} }
@@ -543,6 +545,8 @@ function onOpen (files) {
// In the player, the only drag-drop function is adding subtitles // In the player, the only drag-drop function is adding subtitles
var isInPlayer = state.location.current().url === 'player' var isInPlayer = state.location.current().url === 'player'
if (isInPlayer) { if (isInPlayer) {
// always autoselect one of the newly added subtitle tracks
state.playing.subtitles.selectedIndex = -1
return files.filter(isSubtitle).forEach((file) => addSubtitle(file, true)) return files.filter(isSubtitle).forEach((file) => addSubtitle(file, true))
} }