mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-08 12:37:05 +03:00
Fix getting locked category
This commit is contained in:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user