mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-12 22:47:18 +03:00
Add an Export Segments button to the unsubmitted segments list
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
|
|
||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
|
import { exportTimes } from "../utils/exporter";
|
||||||
|
|
||||||
export interface UnsubmittedVideosListItemProps {
|
export interface UnsubmittedVideosListItemProps {
|
||||||
videoID: string;
|
videoID: string;
|
||||||
@@ -40,6 +41,12 @@ class UnsubmittedVideoListItem extends React.Component<UnsubmittedVideosListItem
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td id={this.props.videoID + "UnsubmittedVideoActions"}>
|
<td id={this.props.videoID + "UnsubmittedVideoActions"}>
|
||||||
|
<div id={this.props.videoID + "ExportSegmentsAction"}
|
||||||
|
className="option-button inline low-profile"
|
||||||
|
onClick={this.exportSegments.bind(this)}>
|
||||||
|
{chrome.i18n.getMessage("exportSegments")}
|
||||||
|
</div>
|
||||||
|
{" "}
|
||||||
<div id={this.props.videoID + "ClearSegmentsAction"}
|
<div id={this.props.videoID + "ClearSegmentsAction"}
|
||||||
className="option-button inline low-profile"
|
className="option-button inline low-profile"
|
||||||
onClick={this.clearSegments.bind(this)}>
|
onClick={this.clearSegments.bind(this)}>
|
||||||
@@ -55,10 +62,20 @@ class UnsubmittedVideoListItem extends React.Component<UnsubmittedVideosListItem
|
|||||||
|
|
||||||
clearSegments(): void {
|
clearSegments(): void {
|
||||||
if (confirm(chrome.i18n.getMessage("clearThis"))) {
|
if (confirm(chrome.i18n.getMessage("clearThis"))) {
|
||||||
delete Config.config.unsubmittedSegments[this.props.videoID]
|
delete Config.config.unsubmittedSegments[this.props.videoID];
|
||||||
Config.forceSyncUpdate("unsubmittedSegments")
|
Config.forceSyncUpdate("unsubmittedSegments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportSegments(): void {
|
||||||
|
navigator.clipboard.writeText(exportTimes(Config.config.unsubmittedSegments[this.props.videoID]))
|
||||||
|
.then(() => {
|
||||||
|
alert(chrome.i18n.getMessage("CopiedExclamation"));
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
alert(chrome.i18n.getMessage("copyDebugInformationFailed"));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UnsubmittedVideoListItem;
|
export default UnsubmittedVideoListItem;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class UnsubmittedVideosComponent extends React.Component<UnsubmittedVideosProps,
|
|||||||
{videoCount > 0 && <div className="option-button inline" onClick={() => this.setState({tableVisible: !this.state.tableVisible})}>
|
{videoCount > 0 && <div className="option-button inline" onClick={() => this.setState({tableVisible: !this.state.tableVisible})}>
|
||||||
{chrome.i18n.getMessage(this.state.tableVisible ? "hideUnsubmittedSegments" : "showUnsubmittedSegments")}
|
{chrome.i18n.getMessage(this.state.tableVisible ? "hideUnsubmittedSegments" : "showUnsubmittedSegments")}
|
||||||
</div>}
|
</div>}
|
||||||
|
{" "}
|
||||||
<div className="option-button inline" onClick={this.clearAllSegments}>
|
<div className="option-button inline" onClick={this.clearAllSegments}>
|
||||||
{chrome.i18n.getMessage("clearUnsubmittedSegments")}
|
{chrome.i18n.getMessage("clearUnsubmittedSegments")}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user