瀏覽代碼

Merge pull request #556 from bershanskiy/fix-onInstalled

Fix: do not open changelog if not needed
Dmitrii Selivanov 3 年之前
父節點
當前提交
c3c13738e7
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      Extensions/combined/ryd.background.js

+ 13 - 0
Extensions/combined/ryd.background.js

@@ -73,6 +73,18 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
   }
 });
 
+api.runtime.onInstalled.addListener((details) => {
+  if (
+    // No need to show changelog if its was a browser update (and not extension update)
+    details.reason === "browser_update" ||
+    // No need to show changelog if developer just reloaded the extension
+    (details.reason === "update" &&
+      details.previousVersion === chrome.runtime.getManifest().version)
+  )
+    return;
+  api.tabs.create({url: api.runtime.getURL("/changelog/3/changelog_3.0.html")});
+})
+
 // api.storage.sync.get(['lastShowChangelogVersion'], (details) => {
 //   if (extConfig.showUpdatePopup === true &&
 //     details.lastShowChangelogVersion !== chrome.runtime.getManifest().version
@@ -84,6 +96,7 @@ api.runtime.onMessage.addListener((request, sender, sendResponse) => {
 //   }
 // });
 
+
 async function sendVote(videoId, vote) {
   api.storage.sync.get(null, async (storageResult) => {
     if (!storageResult.userId || !storageResult.registrationConfirmed) {