Load existing chapters

This commit is contained in:
Ajay
2022-02-22 21:22:30 -05:00
parent cf3b3c5c48
commit 2ebc5489cd
7 changed files with 90 additions and 28 deletions

View File

@@ -29,7 +29,7 @@ export default class Utils {
this.backgroundScriptContainer = backgroundScriptContainer;
}
async wait<T>(condition: () => T | false, timeout = 5000, check = 100): Promise<T> {
async wait<T>(condition: () => T, timeout = 5000, check = 100): Promise<T> {
return GenericUtils.wait(condition, timeout, check);
}
@@ -442,20 +442,6 @@ export default class Utils {
return formatted;
}
getFormattedTimeToSeconds(formatted: string): number | null {
const fragments = /^(?:(?:(\d+):)?(\d+):)?(\d*(?:[.,]\d+)?)$/.exec(formatted);
if (fragments === null) {
return null;
}
const hours = fragments[1] ? parseInt(fragments[1]) : 0;
const minutes = fragments[2] ? parseInt(fragments[2] || '0') : 0;
const seconds = fragments[3] ? parseFloat(fragments[3].replace(',', '.')) : 0;
return hours * 3600 + minutes * 60 + seconds;
}
shortCategoryName(categoryName: string): string {
return chrome.i18n.getMessage("category_" + categoryName + "_short") || chrome.i18n.getMessage("category_" + categoryName);
}
@@ -529,4 +515,8 @@ export default class Utils {
Config.forceLocalUpdate("downvotedSegments");
}
chaptersEnabled(): boolean {
return Config.config.renderAsChapters && !!this.getCategorySelection("chapter");
}
}