Fix getting locked category

This commit is contained in:
Ajay Ramachandran
2021-10-13 23:57:59 -04:00
parent 27f5997e5a
commit fc7fc693ed
2 changed files with 10 additions and 6 deletions

View File

@@ -254,7 +254,7 @@ class SponsorTimeEditComponent extends React.Component<SponsorTimeEditProps, Spo
elements.push( elements.push(
<option value={category} <option value={category}
key={category} key={category}
className={this.categoryLockedClass(category)}> className={this.getCategoryLockedClass(category)}>
{chrome.i18n.getMessage("category_" + category)} {chrome.i18n.getMessage("category_" + category)}
</option> </option>
); );

View File

@@ -37,7 +37,7 @@ let videoInfo: VideoInfo = null;
// The channel this video is about // The channel this video is about
let channelIDInfo: ChannelIDInfo; let channelIDInfo: ChannelIDInfo;
// Locked Categories in this tab, like: ["sponsor","intro","outro"] // Locked Categories in this tab, like: ["sponsor","intro","outro"]
const lockedCategories: Category[] = []; let lockedCategories: Category[] = [];
// Skips are scheduled to ensure precision. // Skips are scheduled to ensure precision.
// Skips are rescheduled every seeking event. // Skips are rescheduled every seeking event.
@@ -234,6 +234,7 @@ function resetValues() {
status: ChannelIDStatus.Fetching, status: ChannelIDStatus.Fetching,
id: null id: null
}; };
lockedCategories = [];
//empty the preview bar //empty the preview bar
if (previewBar !== null) { if (previewBar !== null) {
@@ -808,10 +809,13 @@ async function lockedSegmentsLookup(): Promise<void> {
async function lockedCategoriesLookup(id: string): Promise<void> { async function lockedCategoriesLookup(id: string): Promise<void> {
const response = await utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id }); const response = await utils.asyncRequestToServer("GET", "/api/lockCategories", { videoID: id });
if (response.status === 200 && response.ok) { if (response.ok) {
for (const category of JSON.parse(response.responseText).categories) { try {
lockedCategories.push(category); const categoriesResponse = JSON.parse(response.responseText).categories;
} if (Array.isArray(categoriesResponse)) {
lockedCategories = categoriesResponse;
}
} catch (e) { } //eslint-disable-line no-empty
} }
} }