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

Keep download folder path when changing to 'ask for download path' and back #4101

Merged
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
15 changes: 7 additions & 8 deletions src/renderer/components/download-settings/download-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default defineComponent({
},
data: function () {
return {
askForDownloadPath: false,
downloadBehaviorValues: [
'download',
'open'
Expand All @@ -32,6 +31,9 @@ export default defineComponent({
downloadPath: function() {
return this.$store.getters.getDownloadFolderPath
},
askForDownloadPath: function() {
return this.$store.getters.getDownloadAskPath
},
downloadBehaviorNames: function () {
return [
this.$t('Settings.Download Settings.Download in app'),
Expand All @@ -42,15 +44,9 @@ export default defineComponent({
return this.$store.getters.getDownloadBehavior
}
},
mounted: function () {
this.askForDownloadPath = this.downloadPath === ''
},
methods: {
handleDownloadingSettingChange: function (value) {
this.askForDownloadPath = value
if (value === true) {
this.updateDownloadFolderPath('')
}
this.updateDownloadAskPath(value)
},
chooseDownloadingFolder: async function() {
// only use with electron
Expand All @@ -59,9 +55,12 @@ export default defineComponent({
{ properties: ['openDirectory'] }
)

if (folder.canceled) return

this.updateDownloadFolderPath(folder.filePaths[0])
},
...mapActions([
'updateDownloadAskPath',
'updateDownloadFolderPath',
'updateDownloadBehavior'
])
Expand Down
1 change: 1 addition & 0 deletions src/renderer/store/modules/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ const state = {
videoPlaybackRateMouseScroll: false,
videoSkipMouseScroll: false,
videoPlaybackRateInterval: 0.25,
downloadAskPath: true,
downloadFolderPath: '',
downloadBehavior: 'download',
enableScreenshot: false,
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/store/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ const actions = {

const fileName = `${replaceFilenameForbiddenChars(title)}.${extension}`
const errorMessage = i18n.t('Downloading failed', { videoTitle: title })
const askFolderPath = rootState.settings.downloadAskPath
let folderPath = rootState.settings.downloadFolderPath

if (folderPath === '') {
if (askFolderPath) {
const options = {
defaultPath: fileName,
filters: [
Expand Down