Skip to content

Commit

Permalink
Merge pull request #707 from Pat1enceLos/refactor(preference)
Browse files Browse the repository at this point in the history
 fix(main.ts): fix drop folder in mas
  • Loading branch information
ipy authored Jul 5, 2019
2 parents 16b0b3c + fe98c97 commit 05df177
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function getAllValidVideo(onlySubtitle, files) {
videoFiles.push(tempFilePath);
}
});
} else if (!onlySubtitle) {
} else {
files.forEach((tempFilePath) => {
const baseName = path.basename(tempFilePath);
if (baseName.startsWith('.') || fs.statSync(tempFilePath).isDirectory()) return;
Expand Down Expand Up @@ -233,7 +233,7 @@ function registerMainWindowEvent(mainWindow) {
});
finalVideoToOpen = getAllValidVideo(!tmpVideoToOpen.length,
tmpVideoToOpen.concat(tmpSubsToOpen));
if (process.mas && !tmpVideoToOpen.length && tmpSubsToOpen.length) {
if (process.mas && !tmpVideoToOpen.length && tmpSubsToOpen.length && !finalVideoToOpen) {
mainWindow.webContents.send('open-subtitle-in-mas', tmpSubsToOpen[0]);
} else if (tmpVideoToOpen.length + tmpSubsToOpen.length > 0) {
mainWindow.webContents.send('open-file', { onlySubtitle: !tmpVideoToOpen.length, files: finalVideoToOpen });
Expand Down Expand Up @@ -549,7 +549,7 @@ function createWindow() {
// Open file by file association. Currently support 1 file only.
finalVideoToOpen = getAllValidVideo(!tmpVideoToOpen.length,
tmpVideoToOpen.concat(tmpSubsToOpen));
if (process.mas && !tmpVideoToOpen.length && tmpSubsToOpen.length) {
if (process.mas && !tmpVideoToOpen.length && tmpSubsToOpen.length && !finalVideoToOpen) {
mainWindow.webContents.send('open-subtitle-in-mas', tmpSubsToOpen[0]);
} else if (tmpVideoToOpen.length + tmpSubsToOpen.length > 0) {
mainWindow.webContents.send('open-file', { onlySubtitle: !tmpVideoToOpen.length, files: finalVideoToOpen });
Expand Down
22 changes: 13 additions & 9 deletions src/renderer/components/Subtitle/SubtitleRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,20 @@ export default {
watch: {
allCues: {
handler(val: Cue[][], oldVal: Cue[][]) {
for (let i = 0; i < 9; i += 1) {
if (val[i].length < oldVal[i].length && val[i].every((e: Cue) => oldVal[i].includes(e))) {
this.noPositionCues[i] = oldVal[i].map((cue: Cue) => {
cue.hide = !val[i].includes(cue);
return cue;
});
} else {
this.noPositionCues[i] = val[i].map((cue: Cue) => { cue.hide = false; return cue; });
this.noPositionCues = val;
this.$nextTick(() => {
for (let i = 0; i < 9; i += 1) {
if (val[i].length < oldVal[i].length
&& val[i].every((e: Cue) => oldVal[i].includes(e))) {
this.noPositionCues[i] = oldVal[i].map((cue: Cue) => {
cue.hide = !val[i].includes(cue);
return cue;
});
} else {
this.noPositionCues[i] = val[i].map((cue: Cue) => { cue.hide = false; return cue; });
}
}
}
});
},
deep: true,
},
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1560,10 +1560,10 @@ new Vue({
e.preventDefault();
this.$bus.$emit('drop');
this.$store.commit('source', 'drop');
const files = Array.prototype.map.call(e.dataTransfer!.files, (f: File) => f.path);
if (files.every((file: fs.PathLike) => getValidVideoRegex().test(file) && !getValidSubtitleRegex().test(file))
|| this.currentRouteName === 'playing-view') {
const onlyFolders = files.every((file: fs.PathLike) => fs.statSync(file).isDirectory());
const files = Array.prototype.map.call(e.dataTransfer!.files, (f: File) => f.path)
const onlyFolders = files.every((file: fs.PathLike) => fs.statSync(file).isDirectory());
if (this.currentRouteName === 'playing-view' || onlyFolders
|| files.every((file: fs.PathLike) => getValidVideoRegex().test(file) && !getValidSubtitleRegex().test(file))) {
files.forEach((file: fs.PathLike) => this.$electron.remote.app.addRecentDocument(file));
if (onlyFolders) {
this.openFolder(...files);
Expand Down

0 comments on commit 05df177

Please sign in to comment.