فهرست منبع

refactor: promise detection + comments/leftovers

tophf 3 سال پیش
والد
کامیت
4dab582c47
2فایلهای تغییر یافته به همراه3 افزوده شده و 5 حذف شده
  1. 2 3
      src/background/utils/preinject.js
  2. 1 2
      src/popup/views/app.vue

+ 2 - 3
src/background/utils/preinject.js

@@ -28,8 +28,8 @@ const TIME_KEEP_DATA = 5 * 60e3;
 const cache = initCache({
   lifetime: TIME_KEEP_DATA,
   onDispose: contentScriptsAPI && (async val => {
-    if (val && typeof val === 'object') {
-      const reg = (CSAPI_REG in val ? val : await val)[CSAPI_REG];
+    if (val) {
+      const reg = (val.then ? await val : val)[CSAPI_REG];
       if (reg) (await reg).unregister();
     }
   }),
@@ -60,7 +60,6 @@ Object.assign(commands, {
     clearFrameData(tabId, frameId);
     const key = getKey(url, !frameId);
     const cacheVal = cache.pop(key) || prepare(key, url, tabId, frameId, forceContent);
-    /** @type VMGetInjectedDataContainer */
     const data = cacheVal[INJECT] ? cacheVal : await cacheVal;
     const inject = data[INJECT];
     const feedback = data[FEEDBACK];

+ 1 - 2
src/popup/views/app.vue

@@ -75,7 +75,7 @@
         <icon name="arrow" class="icon-collapse"></icon>
         <div class="flex-auto" v-text="scope.title" :data-totals="scope.totals" />
       </div>
-      <div class="submenu" ref="scriptList" tabindex="-1" autofocus>
+      <div class="submenu" ref="scriptList" tabindex="-1">
         <div
           v-for="(item, index) in scope.list"
           :key="index"
@@ -503,7 +503,6 @@ export default {
     },
   },
   mounted() {
-    // Enable scrolling via Home/End/PgUp/PgDn
     this::focusMe();
     keyboardService.enable();
     this.disposeList = [