Fix editing not adding numbers.

Resolves https://github.com/ajayyy/SponsorBlock/issues/273.
This commit is contained in:
Ajay Ramachandran 2020-02-10 18:03:09 -05:00
parent 852912a42b
commit d2779aba86

View file

@ -656,9 +656,9 @@ async function runThePopup(messageListener?: MessageListener) {
tabs[0].id, tabs[0].id,
{message: "getCurrentTime"}, {message: "getCurrentTime"},
function (response) { function (response) {
let minutes = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Minutes" + index); let minutes = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Minutes" + index);
let seconds = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Seconds" + index); let seconds = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Seconds" + index);
minutes.value = String(getTimeInMinutes(response.currentTime)); minutes.value = String(getTimeInMinutes(response.currentTime));
seconds.value = getTimeInFormattedSeconds(response.currentTime); seconds.value = getTimeInFormattedSeconds(response.currentTime);
}); });
@ -667,11 +667,11 @@ async function runThePopup(messageListener?: MessageListener) {
//id start name is whether it is the startTime or endTime //id start name is whether it is the startTime or endTime
//gives back the time in seconds //gives back the time in seconds
function getSponsorTimeEditTimes(idStartName, index) { function getSponsorTimeEditTimes(idStartName, index): number {
let minutes = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Minutes" + index); let minutes = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Minutes" + index);
let seconds = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Seconds" + index); let seconds = <HTMLInputElement> <unknown> document.getElementById(idStartName + "Seconds" + index);
return parseInt(minutes.value) * 60 + seconds.value; return parseInt(minutes.value) * 60 + parseInt(seconds.value);
} }
function saveSponsorTimeEdit(index, closeEditMode = true) { function saveSponsorTimeEdit(index, closeEditMode = true) {
@ -679,16 +679,17 @@ async function runThePopup(messageListener?: MessageListener) {
sponsorTimes[index][1] = getSponsorTimeEditTimes("endTime", index); sponsorTimes[index][1] = getSponsorTimeEditTimes("endTime", index);
//save this //save this
Config.config.sponsorTimes.set(currentVideoID, sponsorTimes); Config.config.sponsorTimes.set(currentVideoID, sponsorTimes);
messageHandler.query({
active: true, messageHandler.query({
currentWindow: true active: true,
}, tabs => { currentWindow: true
messageHandler.sendMessage( }, tabs => {
tabs[0].id, messageHandler.sendMessage(
{message: "sponsorDataChanged"} tabs[0].id,
); {message: "sponsorDataChanged"}
}); );
});
if (closeEditMode) { if (closeEditMode) {
displaySponsorTimes(); displaySponsorTimes();
@ -968,7 +969,7 @@ async function runThePopup(messageListener?: MessageListener) {
secondsDisplay = "0" + secondsDisplay; secondsDisplay = "0" + secondsDisplay;
} }
let formatted = minutes+ ":" + secondsDisplay; let formatted = minutes + ":" + secondsDisplay;
return formatted; return formatted;
} }