Skip to content

Commit

Permalink
Merge pull request #559 from YvonTre/fix(subtitle)-no-bubble-when-no-…
Browse files Browse the repository at this point in the history
…subtitle

fix(subtitle): handle error rejected from fetchOnlinsSubs
  • Loading branch information
ipy committed Apr 4, 2019
2 parents 3694da5 + 614f109 commit 36ba85e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/renderer/components/Subtitle/SubtitleManager.vue
Expand Up @@ -47,7 +47,7 @@ import { Subtitle as subtitleActions } from '@/store/actionTypes';
import SubtitleRenderer from './SubtitleRenderer.vue';
import SubtitleLoader from './SubtitleLoader';
import { localLanguageLoader } from './SubtitleLoader/utils';
import { LOCAL_SUBTITLE_REMOVED } from '../../../shared/notificationcodes';
import { LOCAL_SUBTITLE_REMOVED, REQUEST_TIMEOUT } from '../../../shared/notificationcodes';
export default {
name: 'subtitle-manager',
Expand Down Expand Up @@ -259,8 +259,19 @@ export default {
options: { language, data, id },
}))
.then(sub => this.addSubtitle(this.normalizeSubtitle(sub), videoSrc))
.catch(() => []);
const storedSubs = await Promise.all(storedSubIds.map(retrieveSub)).then(flatten);
.catch(err => (err instanceof Error ? new Error(err) : err));
const storedSubs = await Promise.all(storedSubIds.map(retrieveSub))
.then(subtitleResults => subtitleResults.filter((result) => {
if (result instanceof Error) {
this.addLog('error', {
message: 'Request Timeout .',
errcode: REQUEST_TIMEOUT,
});
return [];
}
return result;
}))
.then(flatten);
if (storedSubs.length) return storedSubs;
}
const hints = this.generateHints(videoSrc);
Expand Down

0 comments on commit 36ba85e

Please sign in to comment.