aboutsummaryrefslogtreecommitdiffhomepage
path: root/background.js
diff options
context:
space:
mode:
authorAjay Ramachandran <[email protected]>2019-08-02 00:54:50 -0400
committerAjay Ramachandran <[email protected]>2019-08-02 00:54:50 -0400
commit6cb07b5be3ebe3d714f89f2da73a7c6e6b22d396 (patch)
tree0d302c42ca8fa26acf392c7ed82d09b9dc851a18 /background.js
parent3d1be7158d1c6ba0403b505bf1d401821060a0f3 (diff)
downloadSponsorBlock-6cb07b5be3ebe3d714f89f2da73a7c6e6b22d396.tar.gz
SponsorBlock-6cb07b5be3ebe3d714f89f2da73a7c6e6b22d396.zip
Fixed the preview sometimes not updating
Diffstat (limited to 'background.js')
-rw-r--r--background.js9
1 files changed, 6 insertions, 3 deletions
diff --git a/background.js b/background.js
index cbc268b9..cbd45531 100644
--- a/background.js
+++ b/background.js
@@ -39,7 +39,10 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
//this allows the callback to be called later by the submitTimes function
return true;
} else if (request.message == "addSponsorTime") {
- addSponsorTime(request.time, request.videoID);
+ addSponsorTime(request.time, request.videoID, callback);
+
+ //this allows the callback to be called later
+ return true;
} else if (request.message == "getSponsorTimes") {
getSponsorTimes(request.videoID, function(sponsorTimes) {
callback({
@@ -85,7 +88,7 @@ function getSponsorTimes(videoID, callback) {
});
}
-function addSponsorTime(time, videoID) {
+function addSponsorTime(time, videoID, callback) {
getSponsorTimes(videoID, function(sponsorTimes) {
//add to sponsorTimes
if (sponsorTimes.length > 0 && sponsorTimes[sponsorTimes.length - 1].length < 2) {
@@ -101,7 +104,7 @@ function addSponsorTime(time, videoID) {
//save this info
let sponsorTimeKey = "sponsorTimes" + videoID;
- chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
+ chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes}, callback);
});
}